ubuntu无法安装build-essential的错误

ubuntu使用apt命令安装build-essential提示依赖不满足,错误如下:

root@606fc6c54658:/# apt install build-essential
Reading package lists... Done
Building dependency tree... Done
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:
 libatomic1 : Depends: gcc-12-base (= 12-20220319-1ubuntu1) but 12.3.0-1ubuntu1~22.04 is to be installed
 libc6-dev : Depends: libc6 (= 2.35-0ubuntu3) but 2.35-0ubuntu3.6 is to be installed
             Depends: libtirpc-dev but it is not going to be installed
             Depends: libnsl-dev but it is not going to be installed
 libcc1-0 : Depends: gcc-12-base (= 12-20220319-1ubuntu1) but 12.3.0-1ubuntu1~22.04 is to be installed
 libgomp1 : Depends: gcc-12-base (= 12-20220319-1ubuntu1) but 12.3.0-1ubuntu1~22.04 is to be installed
 libitm1 : Depends: gcc-12-base (= 12-20220319-1ubuntu1) but 12.3.0-1ubuntu1~22.04 is to be installed
 liblsan0 : Depends: gcc-12-base (= 12-20220319-1ubuntu1) but 12.3.0-1ubuntu1~22.04 is to be installed
 libquadmath0 : Depends: gcc-12-base (= 12-20220319-1ubuntu1) but 12.3.0-1ubuntu1~22.04 is to be installed
 libubsan1 : Depends: gcc-12-base (= 12-20220319-1ubuntu1) but 12.3.0-1ubuntu1~22.04 is to be installed
 perl : Depends: perl-base (= 5.34.0-3ubuntu1) but 5.34.0-3ubuntu1.3 is to be installed
        Recommends: netbase but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

试图更新源提示如下:

root@606fc6c54658:/# apt update
Get:1 http://mirrors.ustc.edu.cn/ubuntu jammy InRelease [270 kB]
Get:2 http://mirrors.ustc.edu.cn/ubuntu jammy-updates InRelease [119 kB]
Get:3 http://mirrors.ustc.edu.cn/ubuntu jammy-backports InRelease [109 kB]
Get:4 http://mirrors.ustc.edu.cn/ubuntu jammy/universe amd64 Packages [17.5 MB]
Get:5 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Get:6 http://mirrors.ustc.edu.cn/ubuntu jammy/restricted amd64 Packages [164 kB]
Get:7 http://mirrors.ustc.edu.cn/ubuntu jammy/main amd64 Packages [1792 kB]
Get:8 http://mirrors.ustc.edu.cn/ubuntu jammy/multiverse amd64 Packages [266 kB]
Reading package lists... Done
E: Release file for http://mirrors.ustc.edu.cn/ubuntu/dists/jammy-updates/InRelease is not valid yet (invalid for another 37d 6h 29min 32s). Updates for this repository will not be applied.
E: Release file for http://mirrors.ustc.edu.cn/ubuntu/dists/jammy-backports/InRelease is not valid yet (invalid for another 25d 22h 20min 18s). Updates for this repository will not be applied.
E: Release file for http://security.ubuntu.com/ubuntu/dists/jammy-security/InRelease is not valid yet (invalid for another 37d 9h 9min 36s). Updates for this repository will not be applied.

注意看提示“...  is not valid yet (invalid for another 37d 9h 9min 36s). Updates for this repository will not be applied.”

通过date命令查看时间,发现与当前时间不一致,于是用ntpdate更新到最新时间,然后再执行apt update && apt install build-essential 即可成功安装。

ntpdate cn.pool.ntp.org

apt update

apt install build-essential

家庄朗普斯科技有限公司,www.lammps.cn,主要开展云计算、服务器、集群软硬件一体化方案、超算租赁相关业务。

  • 21
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
如果你需要指定安装源来安装 `build-essential`,可以通过编辑 `/etc/apt/sources.list` 文件来实现。 1.备份 `/etc/apt/sources.list` 文件 在编辑 `/etc/apt/sources.list` 文件之前,建议你备份一下该文件,以防止操作不当造成系统问题。 ``` sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak ``` 2.编辑 `/etc/apt/sources.list` 文件 使用文本编辑器打开 `/etc/apt/sources.list` 文件,可以通过以下命令打开该文件: ``` sudo nano /etc/apt/sources.list ``` 在该文件中添加指定源的地址,例如,如果你要使用阿里云的源,可以在文件中添加以下内容: ``` deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse ``` 3.更新源并安装 `build-essential` 保存文件后,运行以下命令更新源并安装 `build-essential`: ``` sudo apt-get update sudo apt-get install build-essential ``` 安装完成后,可以通过以下命令验证 `build-essential` 是否安装成功: ``` gcc --version ``` 希望这个回答能够帮到你!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值