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?
Best Answer
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:
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").