
Lately, I’ve been working mainly on a Windows 10 machine, and using WSL for all my Linux needs. I have Ubunt 20.04 installed under WSL, working with some Java and python apps, but today I wanted to install the build-essential package but was unable to:
$ sudo apt install build-essential 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: build-essential : Depends: libc6-dev but it is not going to be installed or libc-dev Depends: g++ (>= 4:9.2) but it is not going to be installed E: Unable to correct problems, you have held broken packages.
Note: if you have this exact problem and are in a hurry, just go to the last paragraph to see the commands to execute to have build-essential installed.
Two dependencies could not be met: libc6-dev and g++. This is weird. I haven’t had this problem before (build-essential is a quite common package for Ubuntu installations), I’m not sure if this affects a “native” Ubuntu installation (or a non WSL one), but it probably does.
Tried to install libc6-dev:
$ sudo apt install libc6-dev 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: libc6-dev : Depends: libc6 (= 2.31-0ubuntu9.2) but 2.31-0ubuntu9.3 is to be installed E: Unable to correct problems, you have held broken packages.
Ok, libc6-dev depends on libc6-dev, but it seems the versions do not match: we have libc6 version 2.31-0ubuntu9.3 but libc6-dev depends on the previous 2.31-0ubuntu9.2.
We can install this previous libc6 version (downgrade it), first check if it’s still available. The -a option for the show command shows all available versions of a package:
$ apt show -a libc6 Package: libc6 Version: 2.31-0ubuntu9.3 Status: install ok installed Priority: required Section: libs Source: glibc Maintainer: Ubuntu DevelopersOriginal-Maintainer: GNU Libc Maintainers Installed-Size: 13.6 MB Depends: libgcc-s1, libcrypt1 (>= 1:4.4.10-10ubuntu4) Recommends: libidn2-0 (>= 2.0.5~) Suggests: glibc-doc, debconf | debconf-2.0, locales Conflicts: openrc (<< 0.27-2~) Breaks: hurd (<< 1:0.9.git20170910-1), iraf-fitsutil (<< 2018.07.06-4), libtirpc1 (<< 0.2.3), locales (<< 2.31), locales-all (<< 2.31), nocache (<< 1.1-1~), nscd (<< 2.31), r-cran-later (<< 0.7.5+dfsg-2), wcc (<< 0.0.2+dfsg-3) Replaces: libc6-amd64 Homepage: https://www.gnu.org/software/libc/libc.html Original-Vcs-Browser: https://salsa.debian.org/glibc-team/glibc Original-Vcs-Git: https://salsa.debian.org/glibc-team/glibc.git Download-Size: unknown APT-Manual-Installed: yes APT-Sources: /var/lib/dpkg/status Description: GNU C Library: Shared libraries Contains the standard libraries that are used by nearly all programs on the system. This package includes shared versions of the standard C library and the standard math library, as well as many others. Package: libc6 Version: 2.31-0ubuntu9.2 Priority: required Section: libs Source: glibc Origin: Ubuntu Maintainer: Ubuntu Developers Original-Maintainer: GNU Libc Maintainers Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 13.6 MB Depends: libgcc-s1, libcrypt1 (>= 1:4.4.10-10ubuntu4) Recommends: libidn2-0 (>= 2.0.5~) Suggests: glibc-doc, debconf | debconf-2.0, locales Conflicts: openrc (<< 0.27-2~) Breaks: hurd (<< 1:0.9.git20170910-1), iraf-fitsutil (<< 2018.07.06-4), libtirpc1 (<< 0.2.3), locales (<< 2.31), locales-all (<< 2.31), nocache (<< 1.1-1~), nscd (<< 2.31), r-cran-later (<< 0.7.5+dfsg-2), wcc (<< 0.0.2+dfsg-3) Replaces: libc6-amd64 Homepage: https://www.gnu.org/software/libc/libc.html Task: minimal Original-Vcs-Browser: https://salsa.debian.org/glibc-team/glibc Original-Vcs-Git: https://salsa.debian.org/glibc-team/glibc.git Download-Size: 2715 kB APT-Sources: http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages Description: GNU C Library: Shared libraries Contains the standard libraries that are used by nearly all programs on the system. This package includes shared versions of the standard C library and the standard math library, as well as many others. Package: libc6 Version: 2.31-0ubuntu9 Priority: required Section: libs Source: glibc Origin: Ubuntu Maintainer: Ubuntu Developers Original-Maintainer: GNU Libc Maintainers Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 13.6 MB Depends: libgcc-s1, libcrypt1 (>= 1:4.4.10-10ubuntu4) Recommends: libidn2-0 (>= 2.0.5~) Suggests: glibc-doc, debconf | debconf-2.0, locales Conflicts: openrc (<< 0.27-2~) Breaks: hurd (<< 1:0.9.git20170910-1), iraf-fitsutil (<< 2018.07.06-4), libtirpc1 (<< 0.2.3), locales (<< 2.31), locales-all (<< 2.31), nocache (<< 1.1-1~), nscd (<< 2.31), r-cran-later (<< 0.7.5+dfsg-2), wcc (<< 0.0.2+dfsg-3) Replaces: libc6-amd64 Homepage: https://www.gnu.org/software/libc/libc.html Task: minimal Download-Size: 2713 kB APT-Sources: http://archive.ubuntu.com/ubuntu focal/main amd64 Packages Description: GNU C Library: Shared libraries Contains the standard libraries that are used by nearly all programs on the system. This package includes shared versions of the standard C library and the standard math library, as well as many others.
We have versions 2.31-0ubuntu9.3, 2.31-0ubuntu9.2 and 2.31-0ubuntu9. Let's install the one required by libc6-dev:
$ sudo apt install libc6=2.31-0ubuntu9.2 Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: glibc-doc The following packages will be DOWNGRADED: libc6 0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 0 not upgraded. Need to get 2715 kB of archives. After this operation, 0 B of additional disk space will be used. Do you want to continue? [Y/n] Get:1 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libc6 amd64 2.31-0ubuntu9.2 [2715 kB] Fetched 2715 kB in 2s (1695 kB/s) Preconfiguring packages ... dpkg: warning: downgrading libc6:amd64 from 2.31-0ubuntu9.3 to 2.31-0ubuntu9.2 (Reading database ... 89025 files and directories currently installed.) Preparing to unpack .../libc6_2.31-0ubuntu9.2_amd64.deb ... Unpacking libc6:amd64 (2.31-0ubuntu9.2) over (2.31-0ubuntu9.3) ... Setting up libc6:amd64 (2.31-0ubuntu9.2) ... Processing triggers for libc-bin (2.31-0ubuntu9.3) ...
Let's try to install build-essential again:
$ sudo apt install build-essential Reading package lists... Done Building dependency tree Reading state information... Done Preparing to unpack .../12-libalgorithm-diff-xs-perl_0.04-6_amd64.deb ... Unpacking libalgorithm-diff-xs-perl (0.04-6) ... Selecting previously unselected package libalgorithm-merge-perl. Preparing to unpack .../13-libalgorithm-merge-perl_0.08-3_all.deb ... Unpacking libalgorithm-merge-perl (0.08-3) ... Selecting previously unselected package manpages-dev. Preparing to unpack .../14-manpages-dev_5.05-1_all.deb ... Unpacking manpages-dev (5.05-1) ... Setting up manpages-dev (5.05-1) ... Setting up libalgorithm-diff-perl (1.19.03-2) ... Setting up linux-libc-dev:amd64 (5.4.0-86.97) ... Setting up libfakeroot:amd64 (1.24-1) ... Setting up dpkg-dev (1.19.7ubuntu3) ... Setting up fakeroot (1.24-1) ... update-alternatives: using /usr/bin/fakeroot-sysv to provide /usr/bin/fakeroot (fakeroot) in auto mode Setting up libcrypt-dev:amd64 (1:4.4.10-10ubuntu4) ... Setting up libc-dev-bin (2.31-0ubuntu9.2) ... Setting up libalgorithm-diff-xs-perl (0.04-6) ... Setting up libalgorithm-merge-perl (0.08-3) ... Setting up libc6-dev:amd64 (2.31-0ubuntu9.2) ... Setting up libstdc++-9-dev:amd64 (9.3.0-17ubuntu1~20.04) ... Setting up g++-9 (9.3.0-17ubuntu1~20.04) ... Setting up g++ (4:9.3.0-1ubuntu2) ... update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode Setting up build-essential (12.8ubuntu1.1) ... Processing triggers for man-db (2.9.1-1) ... Processing triggers for libc-bin (2.31-0ubuntu9.3) ...
Done!
In summary: you need to downgrade libc6 package to version 2.31-0ubuntu9.2, then you'll be able to install build-essential and its dependencies.
$ sudo apt install libc6=2.31-0ubuntu9.2 $ sudo apt install build-essential
Thank you so much for this post! I just ran into this very issue and it confused the hell out of me!
Glad it was useful for you! 🙂