11

I am trying to install for example mosquitto package with apt then I do

sudo apt-get install mosquitto

and I get an error

 dpkg: error: fgets gave an empty string from '/var/lib/dpkg/triggers/Unincorp'
 E: Sub-process /usr/bin/dpkg returned an error code (2)

I really don't know what can I do to fix it.
Using Ubuntu Release: 20.10

dahan raz
  • 381
  • The issue is only with mosquitto? I would restart and try a sudo apt install -f or sudo dpkg --configure -a – Pablo Bianchi Nov 19 '20 at 18:26
  • No, it happens with every package I try to install and the dpkg command returns the same error dpkg: error: fgets gave an empty string from '/var/lib/dpkg/triggers/Unincorp' – dahan raz Nov 19 '20 at 18:28

1 Answers1

17

Finally found the answer to this problem, all you need to do is

sudo rm /var/lib/dpkg/triggers/Unincorp
sudo touch /var/lib/dpkg/triggers/Unincorp

and then just run

sudo dpkg --configure -a

IDK why this solves the problem but I guess it's because the file was corrupted...

dahan raz
  • 381
  • this worked for me as well but I found it to be overkill. E.G. initially it attempted to configure a secure boot password (normally you can have secure boot on is bios without password) and there was no "without password" option. so I had to kill the terminal, reboot, go into bios, turn off secure boot, then try these commands again and then it worked. but I'm pretty sure for one small corrupted file you shouldn't need to reconfigure the entire system. Anyways thanks for this worked for me. – tatsu Aug 07 '23 at 19:25