尝试重新安装包时出错

尝试重新安装包时出错

我第一次运行sudo dpkg --remove jenkins并得到了回应:

dpkg: error processing package jenkins (--remove):
package is in a very bad inconsistent state; you should
reinstall it before attempting a removal
Errors were encountered while processing:
    jenkins

因此我尝试,sudo apt-get --reinstall install jenkins结果是:

    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
The following packages will be upgraded:
  jenkins
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/68.9 MB of archives.
After this operation, 895 kB of additional disk space will be used.
Selecting previously unselected package jenkins.
(Reading database ... 346826 files and directories currently installed.)
Preparing to unpack .../jenkins_2.19.1_all.deb ...
Not configured to run standalone
invoke-rc.d: initscript jenkins, action "stop" failed.
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg: trying script from the new package instead ...
Not configured to run standalone
invoke-rc.d: initscript jenkins, action "stop" failed.
dpkg: error processing archive /var/cache/apt/archives/jenkins_2.19.1_all.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
Not configured to run standalone
invoke-rc.d: initscript jenkins, action "start" failed.
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/jenkins_2.19.1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

谁能告诉我该怎么做才能修复和更新该软件包?

答案1

您必须在命令--force-overwrite上添加后缀dpkg,这将覆盖导致错误的文件。

sudo dpkg -r --force-overwrite (file)

就你的情况而言,

sudo dpkg -r --force-overwrite /var/cache/apt/archives/jenkins_2.19.1_all.deb

通过运行以下命令确保所有问题都已修复:

sudo apt-get -f install

相关内容