In the complete output of sudo apt update
or sudo apt upgrade
or sudo apt install -f
you should find some messages from dpkg
about what actually went wrong.
These lines will start with dpkg:
since that's the name of the program returning the error. The lines of output immediately preceding or following these lines are often the most helpful.
A few examples of the many possible errors you might see:
Setting up install-info (6.4.90.dfsg.1-1build1) ...
/usr/sbin/update-info-dir: 3: /etc/environment: $: not found
dpkg: error processing package install-info (--configure):
subprocess installed post-installation script returned error exit status 127
This means that the post-installation script could not run. Shells use an exit status of 127 to mean "command not found," so a command called by the post-inst script was not found. The lines before the dpkg
line give a hint as to the reason: there is something wrong with the /etc/environment
file (which should set environment variables like PATH
).
start: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
No apport report written because the error message indicates its a followup error from a previous failure.
dpkg: error processing package runit (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of git-daemon-run:
git-daemon-run depends on runit; however:
Package runit is not configured yet.
The above error was caused by a bug in the runit
package, which expected to find Upstart installed, although it had been succeeded by systemd as the default init system for Ubuntu. So, the message failed to connect to Upstart
is the best hint, but we need the context to find out how this is causing the package management problem.
Unpacking libjline-java (from .../libjline-java_1.0-1_all.deb) ...
dpkg: error processing /var/cache/apt/archives/libjline-java_1.0-1_all.deb (--unpack):
trying to overwrite '/usr/share/java/jline.jar', which is also in package scala 2.9.2-400
This means there are package conflicts, perhaps caused by having a mixture of repository versions or third party repositories.
TL;DR
In any case where you see the error Sub-process /usr/bin/dpkg returned an error code (1)
, you need to look above for lines starting with dpkg:
and the lines before and after them for useful clues to what went wrong. Try searching for these specific errors.
If you are asking a question here or on another support site, make sure you include the command you ran and the complete output, not just the summary error messages.