嗨,我最近将操作系统从 Ubuntu18.04 升级到了 Ubuntu20.04。现在我注意到,当我这样做时sudo apt-get upgrade
,我会保留一些软件包:
The following packages have been kept back:
build-essential cpp g++ gcc gfortran liblapack-dev liblapack3
0 upgraded, 0 newly installed, 0 to remove and 7 not upgraded.
我尝试了上述方法这里。为了解决这个问题,我尝试了
sudo apt-get dist-upgrade
但输出与以前相同。
我也尝试了 sudo aptitude full-upgrade,解决方案也是将软件包保留为当前版本。输出如下:
The following NEW packages will be installed:
cpp-9{ab} g++-9{ab} gcc-9{ab} gfortran-9{ab} libasan5{ab} libgcc-9-dev{ab} libgfortran-9-dev{ab} libgfortran5{ab} libstdc++-9-dev{ab}
libubsan1{ab}
The following packages will be upgraded:
build-essential cpp g++ gcc gfortran liblapack-dev liblapack3
7 packages upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
Need to get 44.5 MB of archives. After unpacking 170 MB will be used.
The following packages have unmet dependencies:
cpp-9 : Depends: gcc-9-base (= 9.3.0-17ubuntu1~20.04) but 9.4.0-1ubuntu1~18.04 is installed
libgfortran-9-dev : Depends: gcc-9-base (= 9.3.0-17ubuntu1~20.04) but 9.4.0-1ubuntu1~18.04 is installed
libasan5 : Depends: gcc-9-base (= 9.3.0-17ubuntu1~20.04) but 9.4.0-1ubuntu1~18.04 is installed
libstdc++-9-dev : Depends: gcc-9-base (= 9.3.0-17ubuntu1~20.04) but 9.4.0-1ubuntu1~18.04 is installed
libubsan1 : Depends: gcc-10-base (= 10.2.0-5ubuntu1~20.04) but 10.3.0-1ubuntu1~18.04~1 is installed
g++-9 : Depends: gcc-9-base (= 9.3.0-17ubuntu1~20.04) but 9.4.0-1ubuntu1~18.04 is installed
libgfortran5 : Depends: gcc-10-base (= 10.2.0-5ubuntu1~20.04) but 10.3.0-1ubuntu1~18.04~1 is installed
gcc-9 : Depends: gcc-9-base (= 9.3.0-17ubuntu1~20.04) but 9.4.0-1ubuntu1~18.04 is installed
gfortran-9 : Depends: gcc-9-base (= 9.3.0-17ubuntu1~20.04) but 9.4.0-1ubuntu1~18.04 is installed
libgcc-9-dev : Depends: gcc-9-base (= 9.3.0-17ubuntu1~20.04) but 9.4.0-1ubuntu1~18.04 is installed
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) build-essential [12.4ubuntu1 (now)]
2) cpp [4:7.4.0-1ubuntu2.3 (now)]
3) cpp-9 [Not Installed]
4) g++ [4:7.4.0-1ubuntu2.3 (now)]
5) g++-9 [Not Installed]
6) gcc [4:7.4.0-1ubuntu2.3 (now)]
7) gcc-9 [Not Installed]
8) gfortran [4:7.4.0-1ubuntu2.3 (now)]
9) gfortran-9 [Not Installed]
10) libasan5 [Not Installed]
11) libgcc-9-dev [Not Installed]
12) libgfortran-9-dev [Not Installed]
13) libgfortran5 [Not Installed]
14) liblapack-dev [3.7.1-4ubuntu1 (now)]
15) liblapack3 [3.7.1-4ubuntu1 (now)]
16) libstdc++-9-dev [Not Installed]
17) libubsan1 [Not Installed]
有人能给我一些建议吗?谢谢!
答案1
事实证明我需要sudo apt-get remove gcc-9-base
然后sudo apt-get install gcc-9-base
。对 gcc-10-base 也需要做同样的事情。
答案2
使用 gcc-9-base 包时我也遇到了类似的错误。对我有用的是:
检查可用版本。 像这样:
$ apt-cache madison gcc-9-base
结果可能看起来像这样:
gcc-9-base | 9.3.0-17ubuntu1~20.04 | http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
gcc-9-base | 9.3.0-17ubuntu1~20.04 | http://archive.ubuntu.com/ubuntu focal-security/main amd64 Packages
gcc-9-base | 9.3.0-10ubuntu2 | http://archive.ubuntu.com/ubuntu focal/main amd64 Packages
选择需要的版本,在本例中为 9.3.0-17ubuntu1~20.04,以及安装像这样:
$ sudo apt-get install gcc-9-base=9.3.0-17ubuntu1~20.04
apt-get 现在应该可以修复你的损坏的软件包。
附言:我知道这个问题现在有点老了,但是对于遇到过类似问题的人来说,这是解决方案。
答案3
PLNewbie 的答案有效:apt remove
和install
[包裹名字] 解决了包裹被“扣留”的问题。
apt install [*packagename*]
无需先删除 [包裹名字] 到目前为止也运行正常。例如
sudo apt install nftables
这解决了自升级到 22.04[0] 以来“保留”的少数软件包问题。它似乎更新或覆盖了之前的版本:
sudo apt list -ia nftables
Listing... Done
nftables/jammy-updates,now 1.0.2-1ubuntu3 amd64
[installed] nftables/jammy 1.0.2-1ubuntu2 amd64
[0] 通过软件更新程序dist-upgrade
我很迅速并且没有明确说明。
答案4
更详细的解释是,当某个包被“保留”时,这意味着有可用的新版本,但是安装该新版本将涉及删除某些包或安装其他新包,而该upgrade
命令不会自动执行这些操作。
您想改用该install
命令;例如:
sudo apt-get install build-essential cpp g++ gcc gfortran liblapack-dev liblapack3
这还将安装(或删除)满足这些升级所需的任何其他软件包。在接受之前,请仔细阅读此输出;如果保留某个软件包的原因是因为新版本与您安装的另一个软件包冲突,apt 可能希望通过删除该软件包来解决问题,因此请仔细检查它所说的要删除的内容,以确保这是可以接受的。