当“apt-get install -f”不起作用时,如何修复损坏的软件包?

当“apt-get install -f”不起作用时,如何修复损坏的软件包?

我尝试安装具有类型安全堆栈的 Scala然后就惹上麻烦了。现在我无法用 apt 做太多事情(除了更新),损坏的软件包似乎无法删除/清理:

结果如下apt-get -f install

$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  gstreamer0.10-fluendo-mp3:i386 scala-library liboil0.3:i386
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  scala
The following NEW packages will be installed:
  scala
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
4 not fully installed or removed.
Need to get 21.5 MB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://apt.typesafe.com/ unicorn/main scala all 2.9.2-400 [21.5 MB]
Fetched 21.5 MB in 13s (1,567 kB/s)                                                                          
(Reading database ... 329381 files and directories currently installed.)
Unpacking scala (from .../scala_2.9.2-400_all.deb) ...
dpkg: error processing /var/cache/apt/archives/scala_2.9.2-400_all.deb (--unpack):
 trying to overwrite '/usr/share/java/scala-partest.jar', which is also in package scala-library 2.9.1.dfsg-3
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/scala_2.9.2-400_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

这是我的尝试autoremove

$ apt-get autoremove
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
phdp@desktop:~/work/manuscripts/ideas/ibm_food_webs$ sudo apt-get autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 typesafe-stack : Depends: scala but it is not installed
E: Unmet dependencies. Try using -f.

答案1

我使用以下命令解决了我的问题:

sudo dpkg -i --force-overwrite path-to-the-deb-file

如果--force-overwrite不起作用,请尝试:

sudo dpkg -i --force-overwrite-all path-to-the-deb-file

就你的情况而言:

sudo dpkg -i --force-overwrite /var/cache/apt/archives/scala_2.9.2-400_all.deb

答案2

以下命令有效。

sudo rm -rf /var/lib/dpkg/updates/*
sudo rm -rf /var/lib/apt/lists/*
sudo rm /var/cache/apt/*.bin
sudo apt-get clean
sudo apt-get autoremove
sudo apt-get update
sudo dpkg --configure -a
sudo apt-get install -f

如果仍然出现相同错误则尝试

sudo dpkg --remove --force-remove-reinstreq package_name 

删除软件包后,更新您的系统并重新启动一次。

答案3

删除软件包然后重新配置似乎scala-library可行。所以你走在正确的轨道上。正确的命令如下:

sudo apt-get autoremove
sudo apt-get install -f

您的autoremove命令未成功,因为您没有以root(使用sudo) 的方式运行它。

答案4

轻松打开突触。它会告诉你发现了一个破损的包裹,所以你必须找到破损的包裹,然后把它移除,然后你就可以做任何你想做的事情了。

相关内容