2022年9月11日 星期日

[Linux] apt: error while loading shared libraries: libudev.so.1: cannot open shared object file: No such file or directory @ Ubuntu 18.04

安裝套件時,有碰到 libudev-dev 相關套件太新:

$ sudo apt install libudev-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libudev-dev : Depends: libudev1 (= 237-3ubuntu10.53) but 237-3ubuntu10.54 is to be installed
E: Unable to correct problems, you have held broken packages.

$ dpkg -l | grep libudev
ii  libudev1:amd64                            237-3ubuntu10.54                            amd64        libudev shared library

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.6 LTS
Release: 18.04
Codename: bionic

然後,就耍蠢把他移掉 XD

$ sudo dpkg --purge --force-all libudev1
dpkg: libudev1:amd64: dependency problems, but removing anyway as you requested:
 util-linux depends on libudev1 (>= 183).
 libpci3:amd64 depends on libudev1 (>= 196).
 initramfs-tools-bin depends on libudev1 (>= 183).
 liblvm2app2.2:amd64 depends on libudev1 (>= 183).
 libplymouth4:amd64 depends on libudev1 (>= 183).
 udev depends on libudev1 (= 237-3ubuntu10.54).
 libusb-1.0-0:amd64 depends on libudev1 (>= 183).
 snapd depends on libudev1 (>= 183).
 liblvm2cmd2.02:amd64 depends on libudev1 (>= 183).
 libdevmapper1.02.1:amd64 depends on libudev1 (>= 183).
 open-vm-tools depends on libudev1 (>= 183).
 lvm2 depends on libudev1 (>= 183).
 dosfstools depends on libudev1 (>= 183).
 libapt-pkg5.0:amd64 depends on libudev1 (>= 183).

(Reading database ... 157028 files and directories currently installed.)
Removing libudev1:amd64 (237-3ubuntu10.54) ...
Processing triggers for libc-bin (2.27-3ubuntu1.6) ...

一堆指令都高度依賴不能跑了 XD

$ sudo apt update
apt: error while loading shared libraries: libudev.so.1: cannot open shared object file: No such file or directory

解法也不難,在用 dpkg 裝回來,在 http://archive.ubuntu.com/ubuntu/pool/main/s/systemd/ 尋找

$ wget http://archive.ubuntu.com/ubuntu/pool/main/s/systemd/libudev1_237-3ubuntu10.54_amd64.deb
$ sudo dpkg -i libudev1_237-3ubuntu10.54_amd64.deb
Selecting previously unselected package libudev1:amd64.
(Reading database ... 157024 files and directories currently installed.)
Preparing to unpack libudev1_237-3ubuntu10.54_amd64.deb ...
Unpacking libudev1:amd64 (237-3ubuntu10.54) ...
Setting up libudev1:amd64 (237-3ubuntu10.54) ...
Processing triggers for libc-bin (2.27-3ubuntu1.6) ... 
$ sudo apt update
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Hit:2 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic InRelease
Get:3 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:4 http://ap-tokyo-1-ad-1.clouds.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Fetched 252 kB in 2s (128 kB/s)   
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.

記錄一下,而真實的任務還沒解決,推論應該是裝上舊把對應的 so 路徑修一下即可,目前還是走安全一點的路徑,用虛擬環境/docker來執行

ref:

沒有留言:

張貼留言