安裝新應用程式時 apt 卡住了

安裝新應用程式時 apt 卡住了

當我嘗試使用apt或安裝新軟體包時apt-get,收到此錯誤訊息:

$ sudo apt install sl
E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem. 

所以,我按照說明進行操作:

$ dpkg --configure -a
dpkg: error: requested operation requires superuser privilege
$ sudo dpkg --configure -a
Setting up icaclient (13.10.0.20) ...

這需要很長時間,所以過了一段時間我按 ctrl+c,結果是這樣的:

^Cdpkg: error processing package icaclient (--configure):
installed icaclient package post-installation script subprocess was interrupted
Errors were encountered while processing:
 icaclient

所以現在當我再次嘗試安裝軟體包時,看起來它可以工作:

$ sudo apt install sl
Reading package lists... Done
Building dependency tree       
Reading state information... Done
sl is already the newest version (3.03-17build2).
The following packages were automatically installed and are no longer required:
  libllvm7 linux-headers-4.15.0-50 linux-image-4.15.0-50-generic linux-modules-4.15.0-50-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 398 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n]

按 Y 後:

Setting up icaclient (13.10.0.20) ...

Progress: [  0%] 
[...................................................]

現在它又卡住了,我無法按 ctrl+c 退出它。當我關閉終端螢幕時,它會從帖子的開頭重複。

我該如何解決這個問題?

注意:我每天都使用 icaclient 應用程序,但我可能可以再次安裝它。

答案1

正如上面的錯誤訊息之一所述,它掛在安裝後腳本上。經過一番搜索後,我發現您可以將安裝後腳本儲存在/var/lib/dpkg/info/

所以我可以使用以下方法輕鬆修復它:

sudo rm /var/lib/dpkg/info/icaclient.postinst

之後我必須運行sudo dpkg --configure -a並刪除一些鎖定檔案。

現在 apt 可以正常工作了!

相關內容