E: Sub-process /usr/bin/dpkg returned an error code (1) - but how do I find the meaningful error messages in APT's output?l pwNepg 97189AsycX
I have encountered various package management problems that cause APT commands to fail with output that ends with this line:
E: Sub-process /usr/bin/dpkg returned an error code (1)
Occasionally other error codes may appear such as 100
which means dpkg is not there, but 1
is the most common error code.
Unfortunately this error code tells me almost nothing about what actually caused the error or how I should solve it. Almost every package management issue I see, regardless of its cause or solution, produces the same error!
So, where will I find the useful part of the output, which I can search for online or ask questions about on Ask Ubuntu?
2 Answers
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. In fact, 127
in Bash is command not found, so a command called by the post-inst script was not found. The lines before the dpkg
line give a probable reason - there is no /etc/environment
file to set the PATH variable so the shell that runs the script doesn't look for the necessary commands in the right places.
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.
Apt logs it's actions sequentially, just like a human does.
Simply read the output line-by-line.
Here is a non-apt example. Read it line-by-line and you will see that it tells a story:
I am going to build a tower out of five blocks...
Clearing a working surface in the kitchen.
Kitchen: Put 7 dirty dishes from the counter into the dishwasher
Kitchen: Wiped the counter clean
Opening the box of blocks.
Warning: There are only three blocks in the box.
Build: Placed the first block.
Build: Placed the second block.
Build: Placed the third block.
Build: ERROR: Cannot keep building - ran out of blocks.
Closing the box of blocks.
ERROR (summary): Failed to complete the five-block tower.
Apt and dpkg logging works in exactly the same way - you read the story line-by-line. You see the package manager embark upon it's adventure: prepare, run subtasks, encounter non-fatal problems (Warnings), overcome adversity, etc.
Most of the output is routine, but you need it to mark apt's progress. That context is how you understand what was happening. It really is a story.
Error (1) is common. It's a summary error code, indicating that the problem occurred to a subtask ("some problem building"). Jump backward in the story to where that particular subtask occurred, and you will see the specific detail ("ran out of blocks").