在运行 squeeze 的旧 Debian 机器上,我的 jenkins 安装有缺陷,导致我无法执行大多数基本的 apt 操作,例如安装、升级等。
我试过跑步
sudo dpkg --remove --force-remove-reinstreq jenkins
dpkg: warning: overriding problem because --force enabled:
Package is in a very bad inconsistent state - you should
reinstall it before attempting a removal.
(Reading database ... 139335 files and directories currently installed.)
Removing jenkins ...
Found an incorrect Java version
Java version found:
java version "1.5.0" gij (GNU libgcj) version 4.4.5 Copyright (C) 2007 Free
Software Foundation, Inc. This is free software; see the source for copying
conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.
Aborting
invoke-rc.d: initscript jenkins, action "stop" failed.
dpkg: error processing jenkins (--remove):
subprocess installed pre-removal script returned error exit status 1
Errors were encountered while processing:
jenkins
我已尝试按照此处的指南升级 Java 版本:https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-debian-8
但我得到了与上述类似的错误。我该如何从机器上彻底删除 Jenkins,我不需要它了?
更新:尝试更新 Java 版本后,我现在得到以下信息:
Found an incorrect Java version
Java version found:
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8.13) (6b18-1.8.13-0+squeeze2)
OpenJDK Client VM (build 14.0-b16, mixed mode, sharing)
编辑:尝试了安东尼奥的答案,但得到了以下输出:
Traceback (most recent call last):
File "/usr/bin/apt-listchanges", line 33, in <module>
from ALChacks import *
File "/usr/share/apt-listchanges/ALChacks.py", line 32, in <module>
sys.stderr.write(_("Can't set locale; make sure $LC_* and $LANG are correct!\n"))
NameError: name '_' is not defined
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "sv_SE.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
dpkg: error processing jenkins (--remove):
Package is in a very bad inconsistent state - you should
reinstall it before attempting a removal.
configured to not write apport reports
Errors were encountered while processing:
jenkins
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
我在 Debian 7 Wheezy 上也遇到了同样的问题。
问题是您的 Java 版本已过时。Jenkins 需要 Java 8。每当您尝试卸载 Jenkins 时,您的系统都会尝试执行与 Jenkins 关联的卸载脚本。然后由于您没有正确的 Java 版本,此脚本会失败,并且删除会结束。
我首先尝试升级 Java,但发现同样的失败,因为系统在升级 Java 之前尝试停止 jenkins。即使 Jenkins 根本没有运行,因为你还记得吗?我们没有正确的 Java 版本。
所以我们陷入了某种循环依赖,我们需要打破它。
这对我有用:
- 编辑
/etc/init.d/jenkins
。我喜欢使用 vim,但请使用您喜欢的编辑器。请记住,您需要sudo
权限才能编辑此文件。 - 这是用于启动和停止 Jenkins 的脚本,该脚本意识到我们没有正确的 Java 版本等。
- 将整个文件放在注释下。为此,将符号添加
#
到每行前面。使用 vim,我可以轻松完成:%s/^/#/
- 转到最后一行(
G
在 vim 中)。 - 删除
#
之前的exit 0
,这将告诉系统脚本已成功。 - 现在您可以启动
sudo aptitude remove jenkins
希望对你有用。如果没有用请告诉我。