others-how to solve 'you have held broken packages' when trying to install package on ubuntu?
1. Purpose
In this post, I will show you how to solve ‘you have held broken packages’ error when trying to install package on ubuntu.
when install package:
(base) root@my_ubuntu:/etc/apt# apt-get install g++
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:
libstdc++-7-dev : Depends: libc6-dev (>= 2.13-0ubuntu6) but it is not installable
E: Unable to correct problems, you have held broken packages.
(base) root@my_ubuntu:/etc/apt# apt install libc6-dev
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:
libc6-dev : Depends: libc6 (= 2.27-3ubuntu1.6) but 2.35-0ubuntu3.1 is to be installed
Depends: libc-dev-bin (= 2.27-3ubuntu1.6) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
(base) root@my_ubuntu:/etc/apt#
The core error message is as follows:
you have held broken packages
2. Solution
The error happened because your ubuntu default apt repository is not set properly.
Change your /etc/apt/sources.list
, set its content as follows:
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
Then rerun the command:
apt update
Then if you get the following error:
E: Failed to fetch https://mirrors.tuna.tsinghua.edu.cn/ubuntu/pool/main/l/linux-meta/linux-headers-generic_5.15.0.84.81_amd64.deb Temporary failure resolving 'mirrors.tuna.tsinghua.edu.cn'
E: Failed to fetch https://mirrors.tuna.tsinghua.edu.cn/ubuntu/pool/main/m/mokutil/mokutil_0.6.0-2%7e22.04.2_amd64.deb Temporary failure resolving 'mirrors.tuna.tsinghua.edu.cn'
E: Failed to fetch https://mirrors.tuna.tsinghua.edu.cn/ubuntu/pool/main/s/sosreport/sosreport_4.5.6-0ubuntu1%7e22.04.1_amd64.deb Temporary failure resolving 'mirrors.tuna.tsinghua.edu.cn'
E: Failed to fetch https://mirrors.tuna.tsinghua.edu.cn/ubuntu/pool/main/t/thermald/thermald_2.4.9-1ubuntu0.4_amd64.deb Temporary failure resolving 'mirrors.tuna.tsinghua.edu.cn'
E: Failed to fetch https://mirrors.tuna.tsinghua.edu.cn/ubuntu/pool/main/c/cloud-init/cloud-init_23.2.2-0ubuntu0%7e22.04.1_all.deb Temporary failure resolving 'mirrors.tuna.tsinghua.edu.cn'
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
(base) root@my_ubuntu:/etc/apt# vi /etc/resolv.conf
You can just open /etc/netplan/...yaml
, change your DNS(nameserver) as follows:
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
Then apply your new DNS settings:
netplan apply
ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
3. Summary
In this post, I demonstrated how to ‘you have held broken packages’ when trying to install package on ubuntu. That’s it, thanks for your reading.