0

I first run sudo dpkg --remove jenkins and I get a response :

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

So I then try with sudo apt-get --reinstall install jenkins and result is :

    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)

Anyone can tell what should I do to fix and update the package ?

mt0s
  • 163
  • Try running sudo apt-get clean && sudo apt-get update && sudo apt-get upgrade (last command perform a package upgrade) – Liso Oct 30 '16 at 09:00

1 Answers1

0

You have to add --force-overwrite suffix on dpkg command, this will overwrite file that causing the error.

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

In your case, it would be

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

Make sure everything is fixed by running:

sudo apt-get -f install
Liso
  • 15,377
  • 3
  • 51
  • 80
  • Hey thanks for the answer. I tried the first command but it;s not working (error is illegal package name in specifier must start with an alphanumeric character). So I tried sudo dpkg -r --force-ovewrite jenkins but once again I get the message about needing to reinstall package before attemping a removal. – mt0s Oct 30 '16 at 17:37
  • Anyway did you run second command ? Make sure you write the file too, not just jenkins – Liso Oct 31 '16 at 16:52