最近学习 CMU 的数据库课程,编程作业需要安装 clang-8,但是在 Ubuntu 20.04 安装时却遇到了错误:libclang-common-8-dev (= 1:8.0.1-9) but it is not going to be installed

# apt install clang-8
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:
 clang-8 : Depends: libclang-common-8-dev (= 1:8.0.1-9) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

看上去是软件包冲突导致的错误,但没有显示具体是哪一个包导致了冲突,需要递归安装找到问题根源。

找到原因

继续安装 libclang-common-8-dev,可以看到这次有三个软件包冲突了。

# apt install libclang-common-8-dev
Reading package lists... Done

The following packages have unmet dependencies:
 libclang-common-8-dev : Depends: lib32gcc-s1 (>= 4.2) but it is not going to be installed
                         Depends: lib32stdc++6 (>= 4.1.1) but it is not going to be installed
                         Depends: libc6-i386 (>= 2.17) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

再尝试安装 libc6-i386,发现了问题的根源:libc6-i386 依赖的是 libc6 = 2.31-0ubuntu9.7 版本,但系统已经安装了 2.31-0ubuntu9.8 版本,这就导致了冲突。

# apt install libc6-i386
Reading package lists... Done

The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libc6-i386 : Depends: libc6 (= 2.31-0ubuntu9.7) but 2.31-0ubuntu9.8 is to be installed
E: Unable to correct problems, you have held broken packages.

解决办法

发现问题原因之后就比较好解决了,对 libc6 进行降级:

apt install libc6=2.31-0ubuntu9.7

现在再安装 clang-8 就没有问题了:

# apt install clang-8
Reading package lists... Done

The following NEW packages will be installed:
  binfmt-support clang-8 gcc-10-base:i386 lib32gcc-s1 lib32stdc++6 libc-dev-bin:i386 libc6:i386 libc6-dev libc6-i386
  libclang-common-8-dev libclang1-8 libcrypt1:i386 libffi-dev libgcc-8-dev libgcc-s1:i386 libidn2-0:i386 libllvm8
  libncurses-dev libobjc-8-dev libobjc4 libomp-8-dev libomp5-8 libpfm4 libstdc++-8-dev libtinfo-dev libunistring2:i386
  llvm-8 llvm-8-dev llvm-8-runtime
0 upgraded, 29 newly installed, 1 to remove and 16 not upgraded.
Need to get 72.4 MB of archives.
After this operation, 448 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐