Zan*_*nna 6 package-management apt dpkg dependencies
有时,Ubuntu 用户会遇到来自apt或apt-get形式的错误:
The package some-package needs to be reinstalled, but I can't find an archive for it.Run Code Online (Sandbox Code Playgroud)
我想知道是什么导致了这个错误,以便我可以重现它并尝试找到修复它的安全方法,即使损坏的包很重要并且有很多依赖项。此位的的APT源代码可能会给有点头绪,但我不知道怎么包获取引起错误的状态。
如何在我的(Ubuntu MATE 17.10)系统上测试时产生这个错误?
这是由最近的 Ask Ubuntu 问题以及我长期以来对关闭有关Apt/Synaptic 的此错误的问题感到不安的提示,需要重新安装软件包但找不到它的存档,其答案用于dpkg --force-all删除有问题的软件包。匿名反馈表明此解决方案已对许多用户有效,但我不相信使用--force-all不会导致以后的问题,或者使用此方法删除 APT 等重要软件包是个好主意。
错误“Apt/Synaptic 需要重新安装软件包但找不到它的存档”有时是非特定的。
我看到此错误的最常见时间是将 Ubuntu 从一个版本升级到另一个版本时。
注意:Ubuntu 正在从 apt-get 转换为 apt ,但我在这篇文章中使用了 apt-get 。有关更多信息,请参阅man apt和https://www.debian.org/doc/manuals/debian-reference/ch02.en.html
此错误的最常见原因是用户安装了软件包,然后删除了 .deb,通常使用 sudo apt-get clean
http://manpages.ubuntu.com/manpages/zesty/man8/apt-get.8.html
干净的
Run Code Online (Sandbox Code Playgroud)clean clears out the local repository of retrieved package files. It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/
然后,在某个时间点,dpkg --reconfigure被用户调用,或者通过升级,或者在某个时间点用户尝试重新安装包被重新安装sudo apt-get --reinstall foo或某些变体。
如果 apt 无法在存储库中找到 .deb,要么是因为软件包被删除(罕见),存储库已从系统中删除,或者升级而软件包不在新存储库中,您将收到错误“Apt/Synaptic需要重新安装软件包但找不到它的存档”
但错误可能来自其他原因。
引用 dpkg 手册页中的相关部分(有关详细信息,请参阅http://manpages.ubuntu.com/manpages/trusty/man1/dpkg.1.html)
关于包的信息 dpkg 维护一些关于可用包的可用信息。信息分为三类:状态、选择状态和标志。这些值主要是通过 dselect 来改变的。
包状态
Run Code Online (Sandbox Code Playgroud)not-installed The package is not installed on your system. config-files Only the configuration files of the package exist on the system. half-installed The installation of the package has been started, but not completed for some reason. unpacked The package is unpacked, but not configured. half-configured The package is unpacked and configuration has been started, but not yet completed for some reason. triggers-awaited The package awaits trigger processing by another package. triggers-pending The package has been triggered. installed The package is unpacked and configured OK.行动
Run Code Online (Sandbox Code Playgroud)-i, --install package-file... Install the package. If --recursive or -R option is specified, package-file must refer to a directory instead. Installation consists of the following steps: 1. Extract the control files of the new package. 2. If another version of the same package was installed before the new installation, execute prerm script of the old package. 3. Run preinst script, if provided by the package. 4. Unpack the new files, and at the same time back up the old files, so that if something goes wrong, they can be restored. 5. If another version of the same package was installed before the new installation, execute the postrm script of the old package. Note that this script is executed after the preinst script of the new package, because new files are written at the same time old files are removed. 6. Configure the package. See --configure for detailed information about how this is done.--配置包...|-a|--pending
Run Code Online (Sandbox Code Playgroud)Configure a package which has been unpacked but not yet configured. If -a or --pending is given instead of package, all unpacked but unconfigured packages are configured. To reconfigure a package which has already been configured, try the dpkg-reconfigure(8) command instead. Configuring consists of the following steps: 1. Unpack the conffiles, and at the same time back up the old conffiles, so that they can be restored if something goes wrong. 2. Run postinst script, if provided by the package. /var/lib/dpkg/status Statuses of available packages. This file contains information about whether a package is marked for removing or not, whether it is installed or not, etc. See section INFORMATION ABOUT PACKAGES for more info.
如果手册页是 tl;dr -> 作为安装的一部分,.deb/dpkg/apt 会运行安装前/安装后脚本和其他功能。如果这些安装/删除脚本由于各种原因失败,软件包将被标记为“半安装”(或除未安装/安装之外的某种状态)。在这种不干净的状态下,您有时可能还会看到错误“Apt/Synaptic 需要重新安装软件包但找不到它的存档”。在此示例中,问题不是缺少存档,而是无法通过重新运行来解决的安装前/安装后脚本中的问题。因此,错误有时是非特定的。
首先尝试通过确保启用适当的 ppa / 存储库(例如 Universe 或任何需要的存储库)来修复依赖项。
然后臭名昭著
sudo apt-get install -f
Run Code Online (Sandbox Code Playgroud)
如果您需要帮助,请阅读任何输出和错误消息并在此处发布命令和输出。
尝试重新配置
sudo dpkg --configure -a
Run Code Online (Sandbox Code Playgroud)
这将运行配置脚本。您可以指定一个包而不是 -a,但是当您遇到问题时 -a 更有帮助。
如果您需要帮助,请阅读任何输出和错误消息并在此处发布命令和输出。
尝试查看任何失败的脚本,并在可能的情况下修复脚本中的错误/问题。
尝试删除有问题的包,如有必要,可以强制删除。在这里您必须非常小心,您可以强制删除关键包或更糟糕的关键包集。以下命令从礼貌到不那么礼貌到彻底的强制。按顺序尝试它们。
sudo dpkg --remove $broken_package
sudo dpkg --remove --force-remove-reinstreq $broken_package
sudo dpkg --remove --force-all $broken_package
Run Code Online (Sandbox Code Playgroud)
如果其中任何一项工作,请运行sudo apt-get update && sudo apt-get upgrade,您可能需要运行sudo apt-get -f install和/或sudo dpkg --configure -a也运行。
如果失败,您将需要手动删除包。这可能涉及查找系统上的所有组件并手动删除它们。
使用以下程序
删除dpkg信息(见上)
cd /var/lib/dpkg/info
sudo rm -i package_name*
Run Code Online (Sandbox Code Playgroud)
小心不要在此处删除多余的内容。
最后删除违规包
sudo dpkg --remove --force-remove-reinstreq package_name
Run Code Online (Sandbox Code Playgroud)
然后你应该可以使用 apt
sudo apt-get update
sudo apt-get install -f
sudo apt-get upgrade
Run Code Online (Sandbox Code Playgroud)仅在必要时查找并手动删除系统上剩余的任何文件。这是一个手动过程,可能包括配置文件/etc或手册页或共享数据。使用 find 或 locate 来识别潜在的剩余文件。
显然,您在删除系统文件时应该格外小心。不要rm -Rf在不了解该命令将做什么的情况下删除您不理解和不使用的内容。rm -i可能会更好,因为该-i选项要求确认。
您可以通过手动编辑任何软件包的 dpkg 状态文件/var/lib/dpkg/info并将状态更改为已安装一半来重现此错误消息
sudo nano /var/lib/dpkg/info/some_package
Run Code Online (Sandbox Code Playgroud)
编辑状态行,使其显示
状态:purge reinstreq 安装到一半
然后尝试运行apt-get。
如果这不起作用,请从 ppa 安装包,运行 apt-get clean,删除 ppa,然后尝试重新安装或重新配置包。
抱歉这篇长文章,但我希望这能让您深入了解这个复杂错误消息“Apt/Synaptic 需要重新安装软件包但找不到它的存档”的原因和解决方案
| 归档时间: |
|
| 查看次数: |
1258 次 |
| 最近记录: |