E:无法纠正问题,您持有破损的包裹

Joh*_*lis 151 package-management apt

我正在使用几天前安装的 Ubuntu 13.04。我正在尝试安装nodejsnpm. 我尝试先从命令行安装,然后卸载它。然后东西坏了。

sudo apt-get install -f nodejs npm
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:
 nodejs : Conflicts: npm
E: Unable to correct problems, you have held broken packages.
Run Code Online (Sandbox Code Playgroud)

的输出/etc/apt/sources.list如下:

# deb cdrom:[Ubuntu 13.04 _Raring Ringtail_ - Release amd64 (20130424)]/ raring main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://in.archive.ubuntu.com/ubuntu/ raring main restricted
deb-src http://in.archive.ubuntu.com/ubuntu/ raring main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://in.archive.ubuntu.com/ubuntu/ raring-updates main restricted
deb-src http://in.archive.ubuntu.com/ubuntu/ raring-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://in.archive.ubuntu.com/ubuntu/ raring universe
deb-src http://in.archive.ubuntu.com/ubuntu/ raring universe
deb http://in.archive.ubuntu.com/ubuntu/ raring-updates universe
deb-src http://in.archive.ubuntu.com/ubuntu/ raring-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://in.archive.ubuntu.com/ubuntu/ raring multiverse
deb-src http://in.archive.ubuntu.com/ubuntu/ raring multiverse
deb http://in.archive.ubuntu.com/ubuntu/ raring-updates multiverse
deb-src http://in.archive.ubuntu.com/ubuntu/ raring-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://in.archive.ubuntu.com/ubuntu/ raring-backports main restricted universe multiverse
deb-src http://in.archive.ubuntu.com/ubuntu/ raring-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu raring-security main restricted
deb-src http://security.ubuntu.com/ubuntu raring-security main restricted
deb http://security.ubuntu.com/ubuntu raring-security universe
deb-src http://security.ubuntu.com/ubuntu raring-security universe
deb http://security.ubuntu.com/ubuntu raring-security multiverse
deb-src http://security.ubuntu.com/ubuntu raring-security multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu raring partner
# deb-src http://archive.canonical.com/ubuntu raring partner

## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
deb http://extras.ubuntu.com/ubuntu raring main
deb-src http://extras.ubuntu.com/ubuntu raring main
Run Code Online (Sandbox Code Playgroud)

的输出/etc/apt/sources.list.d/*如下:

deb http://ppa.launchpad.net/chris-lea/node.js/ubuntu raring main
# deb-src http://ppa.launchpad.net/chris-lea/node.js/ubuntu raring main
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
deb http://dl.google.com/linux/chrome/deb/ stable main
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
deb http://dl.google.com/linux/chrome/deb/ stable main
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
deb http://dl.google.com/linux/chrome/deb/ stable main
deb http://deb.opera.com/opera/ stable non-free
deb http://deb.opera.com/opera/ stable non-free
deb http://deb.opera.com/opera/ stable non-free
deb http://deb.opera.com/opera/ stable non-free
Run Code Online (Sandbox Code Playgroud)

小智 303

使用 aptitude 而不是 apt-get。它更聪明。它不仅会为您处理降级冲突的软件包,还会提出一系列建议,询问您希望在许多可能的建议工作方案中选择哪一个。

sudo aptitude install myNewPackage
Run Code Online (Sandbox Code Playgroud)

如果您的机器上还没有 aptitude,请使用

sudo apt-get install aptitude
Run Code Online (Sandbox Code Playgroud)

  • 最好的答案。最近几天我尝试了 apt-get 。凭借 aptitude,这在几秒钟内就解决了:-) (40认同)
  • 谢谢你。我花了很多时间阅读解决问题的不同方法,apt-get 无法解释当 aptitude 刚刚列出特定问题甚至提供解决方案时,我感到震惊。 (8认同)
  • 此解决方案的一个缺点:如果您的软件包首先损坏,您将无法执行 `sudo apt-get install aptitude`。 (6认同)
  • 哇!‘天赋’太棒了!我的 mysql 安装有几个问题,幸运的是它自己解决了我删除了一堆不良依赖项。 (2认同)

Rma*_*ano 35

您应该能够通过以下方式查看保留的包裹列表:

apt-mark showhold 
Run Code Online (Sandbox Code Playgroud)

然后将它们松开

sudo apt-mark unhold <package name>
Run Code Online (Sandbox Code Playgroud)

之后,您应该能够删除冲突的包(似乎是npm),然后重新安装所有包。

如果失败,你可以试试这个aptitude方法——通常它能够更好地解开依赖树。

在这两种情况下,在应用命令时要小心,并仔细检查标记为删除的包列表。

  • 当我用 wine1.6 尝试时,`apt-mark showhold` 什么都不输出。还有其他想法吗?(我也在 [聊天]) :) (126认同)
  • 是的。我也是。对我来说,这个命令从来没有输出过任何东西。 (22认同)
  • 致读者:请务必查看@DragonLord 使用 aptitude 的提示!效果很好。 (6认同)
  • 是的,我同意 --- 通常,`aptitude` 能够以比普通的 `apt` 更好的方式解开依赖关系树。 (6认同)
  • apt-mark showhold 对我没有任何帮助。 (2认同)

小智 5

为了解决这个问题,我只需要先使用下面的命令安装突触,然后一切正常。

sudo apt-get install synaptic
Run Code Online (Sandbox Code Playgroud)