Edit: second answer fixed my problem
The suggested duplicate doesn't fix my problem, as shown below I tried to do that exact same thing without success (output shown below)
I have installed "nrf-udev" package (following this guide) some time ago and now I can't remove and now it's blocking me from upgrading other packages due to errors it's causing.
For example I try:
sudo dpkg --remove nrf-udev
and I get the following:
dpkg: error processing package nrf-udev (--remove):
package is in a very bad inconsistent state; you should
reinstall it before attempting a removal
Errors were encountered while processing:
nrf-udev
When I try to install it to fix this:
$ sudo dpkg -i nrf-udev_1.0.1-all.deb
Selecting previously unselected package nrf-udev.
(Reading database ... 891111 files and directories currently installed.)
Preparing to unpack nrf-udev_1.0.1-all.deb ...
Unpacking nrf-udev (1.0.1) over (1.0.1) ...
Reloading udev rules...
Job for systemd-udevd.service failed. See "systemctl status systemd-udevd.service" and "journalctl -xe" for details.
invoke-rc.d: initscript udev, action "reload" failed.
dpkg: warning: old nrf-udev package post-removal script subprocess returned error exit status 1
dpkg: trying script from the new package instead ...
Reloading udev rules...
Job for systemd-udevd.service failed. See "systemctl status systemd-udevd.service" and "journalctl -xe" for details.
invoke-rc.d: initscript udev, action "reload" failed.
dpkg: error processing archive nrf-udev_1.0.1-all.deb (--install):
new nrf-udev package post-removal script subprocess returned error exit status 1
Reloading udev rules...
Job for systemd-udevd.service failed. See "systemctl status systemd-udevd.service" and "journalctl -xe" for details.
invoke-rc.d: initscript udev, action "reload" failed.
dpkg: error while cleaning up:
new nrf-udev package post-removal script subprocess returned error exit status 1
Errors were encountered while processing:
nrf-udev_1.0.1-all.deb
Following suggestions in the output:
$ sudo systemctl status systemd-udevd.service
Failed to parse bus message: No such device or address
$ journalctl -xe
Journal file /var/log/journal/4ed21a70afb14542b7a7237653af2121/user-1000@9377c5d7ee0c41929c6d3230e7fe0fef-00000000005d1def-000614d5d95a6897.journal uses an unsupported feature, ignoring file.
-- No entries --
Trying to force remove it with dpkg:
$ sudo dpkg --remove --force-remove-reinstreq nrf-udev
dpkg: warning: overriding problem because --force enabled:
dpkg: warning: package is in a very bad inconsistent state; you should
reinstall it before attempting a removal
(Reading database ... 891108 files and directories currently installed.)
Removing nrf-udev (1.0.1) ...
Reloading udev rules...
Job for systemd-udevd.service failed. See "systemctl status systemd-udevd.service" and "journalctl -xe" for details.
invoke-rc.d: initscript udev, action "reload" failed.
dpkg: error processing package nrf-udev (--remove):
installed nrf-udev package post-removal script subprocess returned error exit status 1
Errors were encountered while processing:
nrf-udev
Now even when I try to upgrade packages I get the following:
$ sudo apt upgrade -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: The package nrf-udev needs to be reinstalled, but I can't find an archive for it.
This is on ubuntu20