Skip to content

Instantly share code, notes, and snippets.

@mrcrilly
Last active September 24, 2024 07:19
Show Gist options
  • Save mrcrilly/8111bbfc0d6f4ccb55ac6e54ebc67439 to your computer and use it in GitHub Desktop.
Save mrcrilly/8111bbfc0d6f4ccb55ac6e54ebc67439 to your computer and use it in GitHub Desktop.
libc6-dev : Depends: libc6 (= 2.35-0ubuntu3) but 2.35-0ubuntu3.1 is to be installed

This is a small guide on resolving an issue I was having that prevented me from installing libc6-dev. The issue I was having was as such:

libc6-dev : Depends: libc6 (= 2.35-0ubuntu3) but 2.35-0ubuntu3.1 is to be installed

The libc6-dev package wants to install version 2.35-0ubuntu3, which is (very slightly) "older" than the libc6 package I have installed at version 2.35-0ubuntu3.1 (notice the .1). This basically prevents me from installing libc6-dev which in turn prevents me from installing build-essential. You need build-essential to do a lot of development work, such as compiling C code.

Here is the process I went through, from discovering the problem to solving it, but let's start with the solution straight up.

Solution

For me, it was enough to force the install of the (slightly) "older" version of libc6, as everything else is essentially pinned to that package (libc is actually kind of a big deal in the UNIX world.):

sudo apt install -f libc6=2.35-0ubuntu3 libc6:i386=2.35-0ubuntu3

This will reduce libc6 (which is the 64-bit version) and libc6:i386 (the 32-bit equivalent) down to version 2.35-0ubuntu3 (notice the lack of .1 on the end, now.) This meant I could install what I needed now:

sudo apt install build-essential

Which install libc6-dev successfully.

The Journey

Here's the journey I went through in a bit more detail.

$ sudo apt install build-essential
...

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.35-0ubuntu3) but 2.35-0ubuntu3.1 is to be installed
E: Unable to correct problems, you have held broken packages.

Which means build-essential requires libc6-dev, so you try this:

$ sudo apt install libc6-dev
libc6-dev : Depends: libc6 (= 2.35-0ubuntu3) but 2.35-0ubuntu3.1 is to be installed
E: Unable to correct problems, you have held broken packages.

This means libc6-dev version 2.35-0ubuntu3 cannot be installed against the libc6 version 2.35-0ubuntu3.1 you have installed, and apt won't downgrade the package. To resolve this, you must forcefully downgrade the libc6 package, like this:

$ sudo apt install -f libc6=2.35-0ubuntu3 libc6:i386=2.35-0ubuntu3
...

The following packages will be REMOVED:
  libc6-dbg
The following packages will be DOWNGRADED:
  libc6 libc6:i386
0 to upgrade, 0 to newly install, 2 to downgrade, 1 to remove and 0 not to upgrade.

Notice how libc6:i386 will also need to be downgraded? That's because it's the 32-bit version of the libc6 package and they both must be in sync. Now we install libc6-dev as the versions will match:

$ sudo apt install libc6-dev
...

The following additional packages will be installed:
  libc-dev-bin libc-devtools libcrypt-dev libnsl-dev libtirpc-dev linux-libc-dev manpages-dev rpcsvc-proto
Suggested packages:
  glibc-doc
The following NEW packages will be installed:
  libc-dev-bin libc-devtools libc6-dev libcrypt-dev libnsl-dev libtirpc-dev linux-libc-dev manpages-dev rpcsvc-proto
0 to upgrade, 9 to newly install, 0 to remove and 0 not to upgrade.

And you should be OK. Now you might be thinking, "What if I now do an apt upgrade - won't I get that newer libc6 and libc6-dev setup I originally had (minus libc6-dev)?" No:

$ sudo apt upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.

But now you can circle back around and finally install build-essential:

$ sudo apt install build-essential
...

The following additional packages will be installed:
  dpkg-dev fakeroot g++ g++-11 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libfakeroot libstdc++-11-dev lto-disabled-list
Suggested packages:
  debian-keyring g++-multilib g++-11-multilib gcc-11-doc libstdc++-11-doc
The following NEW packages will be installed:
  build-essential dpkg-dev fakeroot g++ g++-11 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libfakeroot libstdc++-11-dev lto-disabled-list
0 to upgrade, 11 to newly install, 0 to remove and 0 not to upgrade.

This resolved the libc6 and libc6-dev package issue on my Ubuntu 22.04 installation.

sudo apt install build-essential

Which install libc6-dev successfully.

The Journey

Here's the journey I went through in a bit more detail.

$ sudo apt install build-essential
...

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.35-0ubuntu3) but 2.35-0ubuntu3.1 is to be installed
E: Unable to correct problems, you have held broken packages.

Which means build-essential requires libc6-dev, so you try this:

$ sudo apt install libc6-dev
libc6-dev : Depends: libc6 (= 2.35-0ubuntu3) but 2.35-0ubuntu3.1 is to be installed
E: Unable to correct problems, you have held broken packages.

This means libc6-dev version 2.35-0ubuntu3 cannot be installed against the libc6 version 2.35-0ubuntu3.1 you have installed, and apt won't downgrade the package. To resolve this, you must forcefully downgrade the libc6 package, like this:

$ sudo apt install -f libc6=2.35-0ubuntu3 libc6:i386=2.35-0ubuntu3
...

The following packages will be REMOVED:
  libc6-dbg
The following packages will be DOWNGRADED:
  libc6 libc6:i386
0 to upgrade, 0 to newly install, 2 to downgrade, 1 to remove and 0 not to upgrade.

Notice how libc6:i386 will also need to be downgraded? That's because it's the 32-bit version of the libc6 package and they both must be in sync. Now we install libc6-dev as the versions will match:

$ sudo apt install libc6-dev
...

The following additional packages will be installed:
  libc-dev-bin libc-devtools libcrypt-dev libnsl-dev libtirpc-dev linux-libc-dev manpages-dev rpcsvc-proto
Suggested packages:
  glibc-doc
The following NEW packages will be installed:
  libc-dev-bin libc-devtools libc6-dev libcrypt-dev libnsl-dev libtirpc-dev linux-libc-dev manpages-dev rpcsvc-proto
0 to upgrade, 9 to newly install, 0 to remove and 0 not to upgrade.

And you should be OK. Now you might be thinking, "What if I now do an apt upgrade - won't I get that newer libc6 and libc6-dev setup I originally had (minus libc6-dev)?" No:

$ sudo apt upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.

But now you can circle back around and finally install build-essential:

$ sudo apt install build-essential
...

The following additional packages will be installed:
  dpkg-dev fakeroot g++ g++-11 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libfakeroot libstdc++-11-dev lto-disabled-list
Suggested packages:
  debian-keyring g++-multilib g++-11-multilib gcc-11-doc libstdc++-11-doc
The following NEW packages will be installed:
  build-essential dpkg-dev fakeroot g++ g++-11 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libfakeroot libstdc++-11-dev lto-disabled-list
0 to upgrade, 11 to newly install, 0 to remove and 0 not to upgrade.

This resolved the libc6 and libc6-dev package issue on my Ubuntu 22.04 installation.

@melroy89
Copy link

melroy89 commented Sep 3, 2024

I'm using Armbian which is Jammy based. This is using a BananaPi that is only a ARM based platform.

My fix was:

sudo apt install -f  libc6=2.35-0ubuntu3.8

My error I had:

Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 libc6-dev : Depends: libc6 (= 2.35-0ubuntu3.8) but 2.35-0ubuntu3.6 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment