Sub-process /usr/bin/dpkg returned an error code (1)

i trying from yesterday this is not solving. tried with many tutorial

It would help us a lot in helping you, if you elaborated on what exactly you did and its results, as precisely as possible.

Additionally, after adding all the needed information, you should perform the operations described here and post their output in this thread, as well.

Hi,

Could you try cleaning apt cache:

sudo apt-get clean

And then run update once again.

Hi Abhishek, this issue still persists for me.
Here is what I am trying to do.
Basically I want to install postgresql-12 on Ubuntu20.04 machine.
And following - https://www.postgresql.org/download/linux/ubuntu/
It worked for me once, but somewhere I messed up doing lot of things, so I removed it and again tried to install. since then it is just stuck.

Now I am trying to fix the broken install as -
$sudo apt --fix-broken install
Reading package lists... Done Building dependency tree Reading state information... Done Correcting dependencies... Done The following additional packages will be installed: postgresql-13 The following NEW packages will be installed: postgresql-13 0 upgraded, 1 newly installed, 0 to remove and 52 not upgraded. 2 not fully installed or removed. Need to get 15.0 MB of archives. After this operation, 48.7 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://apt.postgresql.org/pub/repos/apt focal-pgdg/main amd64 postgresql-13 amd64 13.1-1.pgdg20.04+1 [15.0 MB] Fetched 15.0 MB in 42s (358 kB/s) Preconfiguring packages ... dpkg: warning: files list file for package 'postgresql-client-common' missing; assuming package has no files currently installed dpkg: warning: files list file for package 'postgresql-client-13' missing; assuming package has no files currently installed dpkg: warning: files list file for package 'postgresql-client-12' missing; assuming package has no files currently installed (Reading database ... 215877 files and directories currently installed.) Preparing to unpack .../postgresql-13_13.1-1.pgdg20.04+1_amd64.deb ... /var/lib/dpkg/tmp.ci/preinst: 11: .: Can't open /usr/share/postgresql-common/maintscripts-functions dpkg: error processing archive /var/cache/apt/archives/postgresql-13_13.1-1.pgdg20.04+1_amd64.deb (--unpack): new postgresql-13 package pre-installation script subprocess returned error exit status 127 Errors were encountered while processing: /var/cache/apt/archives/postgresql-13_13.1-1.pgdg20.04+1_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1)

I tried so many things suggested by internet,and most recently tried cleaning apt cache like you suggested , but no luck, the error still persists.

Try these command one by one:

sudo apt install --reinstall postgresql-client-common
sudo apt install --reinstall postgresql-client-13

I am not sure why it complains of postgresql-client-12 but if the error message complaints about that, try reinstalling that package as well.

I too have this problem please help with a solution.
$ sudo apt-get install -f
Reading package lists… Done
Building dependency tree
Reading state information… Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up lvm2 (2.03.07-1ubuntu3) …
update-initramfs: deferring update (trigger activated)
Failed to restart lvm2-lvmpolld.service: Unit lvm2-lvmpolld.socket is masked.
invoke-rc.d: initscript lvm2-lvmpolld, action “restart” failed.
â—Ź lvm2-lvmpolld.service - LVM2 poll daemon
Loaded: loaded (/lib/systemd/system/lvm2-lvmpolld.service; static)
Active: inactive (dead)
Docs: man:lvmpolld(8)
dpkg: error processing package lvm2 (–configure):
installed lvm2 package post-installation script subprocess returned error exit status 1
Processing triggers for initramfs-tools (0.137ubuntu12) …
update-initramfs: Generating /boot/initrd.img-5.8.0-41-generic
Errors were encountered while processing:
lvm2
E: Sub-process /usr/bin/dpkg returned an error code (1)

It occurred from a regular update

Dear @amamdi, would you mind, being a bit more specific? Before asking your question, you might want to check out the page:

Besides that, the information, you provide seems to be somewhat contradictory:

On one hand, you write “It occurred from a regular update”, on the other you cite a command that is supposed to fix a broken package: sudo apt-get install -f but keeping the package name a secret.

From the output, I guess, you’re trying to install or fix lvm2, the Logical Volume Manager. Please correct me if I’m wrong.

The best way to ask a question, is to assume that your readers are somewhat retarded and need every piece of information presented in a simple, easy to grasp, manner, using short, but complete sentences.

  • 1 What was your original situation?
  • 2 What happened spontaneously, or what did you try to do?
  • 3 What went wrong? What are the consequences?
  • 4 Which were your attempts to remedy the problems? Why and how?
1 Like

I was updating and upgrading my system with the regular ubuntu updates and upgrades.
When one update and upgrade session finished, i noticed the following output:

Setting up lvm2 (2.03.07-1ubuntu3) …
update-initramfs: deferring update (trigger activated)
Failed to restart lvm2-lvmpolld.service: Unit lvm2-lvmpolld.socket is masked.
invoke-rc.d: initscript lvm2-lvmpolld, action “restart” failed.
â—Ź lvm2-lvmpolld.service - LVM2 poll daemon
Loaded: loaded (/lib/systemd/system/lvm2-lvmpolld.service; static)
Active: inactive (dead)
Docs: man:lvmpolld(8)
dpkg: error processing package lvm2 (–configure):
installed lvm2 package post-installation script subprocess returned error exit status 1
Processing triggers for initramfs-tools (0.137ubuntu12) …
update-initramfs: Generating /boot/initrd.img-5.8.0-41-generic
Errors were encountered while processing:
lvm2
E: Sub-process /usr/bin/dpkg returned an error code (1)

Anytime i update or upgrade, other programmes will update and upgrade but this lvm2 will still stick out as not being installed and produce the above report.

I tried method 1-3 of fixing the error as mentioned here https://itsfoss.com/dpkg-returned-an-error-code-1/

Nothing has changed still see the above output anytime im updating and upgrading.

Method 3 is removing the package. What was the output then?

Thank you this was the output: Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 27787 (packagekitd)

Kindly
reboot and try again is usually part of the solution.

1 Like

This implies that the package manager is still running. Probably you tried (unsuccessfully) to install or update and then tried to remove.

@R_G’s (rebooting) is probably the best option to return the system to a stable state. Otherwise, kill -9 27287 might have been my first try.

1 Like

I rebooted and successfully uninstalled the lvm2 package. THANK YOU!

A reboot fixes so many problems :slight_smile:

2 Likes