5

Using Debian Stretch v9.11.

I try to install build-essential, but fails because of unmet dependencies:

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:6.3) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

apt-cache policy shows:

apt-cache policy
Package files:
 100 /var/lib/dpkg/status
     release a=now
 500 http://security.debian.org/debian-security stretch/updates/non-free amd64 Packages
     release v=9,o=Debian,a=oldstable,n=stretch,l=Debian-Security,c=non-free,b=amd64
     origin security.debian.org
 500 http://security.debian.org/debian-security stretch/updates/contrib amd64 Packages
     release v=9,o=Debian,a=oldstable,n=stretch,l=Debian-Security,c=contrib,b=amd64
     origin security.debian.org
 500 http://security.debian.org/debian-security stretch/updates/main amd64 Packages
     release v=9,o=Debian,a=oldstable,n=stretch,l=Debian-Security,c=main,b=amd64
     origin security.debian.org
 500 http://deb.debian.org/debian stretch/non-free amd64 Packages
     release v=9.11,o=Debian,a=oldstable,n=stretch,l=Debian,c=non-free,b=amd64
     origin deb.debian.org
 500 http://deb.debian.org/debian stretch/contrib amd64 Packages
     release v=9.11,o=Debian,a=oldstable,n=stretch,l=Debian,c=contrib,b=amd64
     origin deb.debian.org
 500 http://deb.debian.org/debian stretch/main amd64 Packages
     release v=9.11,o=Debian,a=oldstable,n=stretch,l=Debian,c=main,b=amd64
     origin deb.debian.org

I have following content in /etc/apt/sources.list:

# deb cdrom:[Debian GNU/Linux 9.5.0 _Stretch_ - Official amd64 DVD Binary-1 20180714-10:25]/ stretch contrib main

deb http://deb.debian.org/debian stretch main contrib non-free
deb-src http://deb.debian.org/debian stretch main contrib non-free

# deb http://deb.debian.org/debian stretch-updates main
# deb-src http://deb.debian.org/debian stretch-updates main


# deb http://deb.debian.org/debian-security/ stretch/updates main
# deb-src http://deb.debian.org/debian-security/ stretch/updates main

deb http://security.debian.org/debian-security stretch/updates main contrib non-free
deb-src http://security.debian.org/debian-security stretch/updates main contrib non-free

# add backports
# deb http://ftp.debian.org/debian stretch-backports main


# stretch-updates, previously known as 'volatile'
# A network mirror was not selected during install.  The following entries
# are provided as examples, but you should amend them as appropriate
# for your mirror of choice.
#
# deb http://deb.debian.org/debian/ stretch-updates main contrib
# deb-src http://deb.debian.org/debian/ stretch-updates main contrib

EDIT1: apt-cache policy libc6-dev shows:

apt-cache policy libc6-dev
libc6-dev:
  Installed: (none)
  Candidate: 2.24-11+deb9u4
  Version table:
     2.24-11+deb9u4 500
        500 http://deb.debian.org/debian stretch/main amd64 Packages
     2.24-11+deb9u1 500
        500 http://security.debian.org/debian-security stretch/updates/main amd64 Packages

apt-cache policy g++ shows:

apt-cache policy g++
g++:
  Installed: (none)
  Candidate: 4:6.3.0-4
  Version table:
     4:6.3.0-4 500
        500 http://deb.debian.org/debian stretch/main amd64 Packages

EDIT2: I had deb http://ftp.de.debian.org/debian buster main in /etc/apt/sources.list.d/.mc.list

I remember, that once I had to install a newer mc, which had specific bugfix.

EDIT3:

apt update
Get:1 http://security.debian.org/debian-security stretch/updates InRelease [94.3 kB]
Ign:2 http://deb.debian.org/debian stretch InRelease
Hit:3 http://deb.debian.org/debian stretch Release
Fetched 94.3 kB in 1s (69.7 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.

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

apt-get install --fix-broken
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

EDIT4:

sudo apt install libc6-dev g++
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.24-11+deb9u4) but 2.27-6 is to be installed
Depends: libc-dev-bin (= 2.24-11+deb9u4) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

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:6.3) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

EDIT5

sudo aptitude -f install build-essential
The following NEW packages will be installed:
build-essential dpkg-dev{a} fakeroot{a} g++{a} g++-6{a} libalgorithm-diff-perl{a} libalgorithm-diff-xs-perl{a} libalgorithm-merge-perl{a} libc-dev-bin{ab} libc6-dev{ab} libdpkg-perl{a} libfakeroot{a} libfile-fcntllock-perl{a} libstdc++-6-dev{a} linux-libc-dev{a} manpages-dev{a} 0 packages upgraded, 16 newly installed, 0 to remove and 0 not upgraded. Need to get 17.9 MB of archives. After unpacking 69.7 MB will be used.
The following packages have unmet dependencies:
libc6-dev : Depends: libc6 (= 2.24-11+deb9u4) but 2.27-6 is installed
libc-dev-bin : Depends: libc6 (< 2.25) but 2.27-6 is installed
The following actions will resolve these dependencies:

Keep the following packages at their current version:
1) build-essential [Not Installed]
2) g++ [Not Installed]
3) g++-6 [Not Installed]
4) libc-dev-bin [Not Installed]
5) libc6-dev [Not Installed]
6) libstdc++-6-dev [Not Installed]

Leave the following dependencies unresolved:
7) dpkg-dev recommends build-essential



Accept this solution? [Y/n/q/?]
The following NEW packages will be installed:
dpkg-dev{a} fakeroot{a} libalgorithm-diff-perl{a}
libalgorithm-diff-xs-perl{a} libalgorithm-merge-perl{a}
libdpkg-perl{a} libfakeroot{a} libfile-fcntllock-perl{a}
manpages-dev{a}
The following packages are RECOMMENDED but will NOT be installed: build-essential
0 packages upgraded, 9 newly installed, 0 to remove and 0 not upgraded.
Need to get 5,267 kB of archives. After unpacking 8,773 kB will be used.
Do you want to continue? [Y/n/?]
Get: 1 http://deb.debian.org/debian stretch/main amd64 libdpkg-perl all 1.18.25 [1,287 kB]
Get: 2 http://deb.debian.org/debian stretch/main amd64 dpkg-dev all 1.18.25 [1,595 kB]
Get: 3 http://deb.debian.org/debian stretch/main amd64 libfakeroot amd64 1.21-3.1 [45.7 kB]
Get: 4 http://deb.debian.org/debian stretch/main amd64 fakeroot amd64 1.21-3.1 [85.6 kB]
Get: 5 http://deb.debian.org/debian stretch/main amd64 libalgorithm-diff-perl all 1.19.03-1 [48.7 kB]
Get: 6 http://deb.debian.org/debian stretch/main amd64 libalgorithm-diff-xs-perl amd64 0.04-4+b2 [11.6 kB]
Get: 7 http://deb.debian.org/debian stretch/main amd64 libalgorithm-merge-perl all 0.08-3 [12.7 kB]
Get: 8 http://deb.debian.org/debian stretch/main amd64 libfile-fcntllock-perl amd64 0.22-3+b2 [35.3 kB]
Get: 9 http://deb.debian.org/debian stretch/main amd64 manpages-dev all 4.10-2 [2,145 kB]
Fetched 5,267 kB in 0s (15.0 MB/s)
Selecting previously unselected package libdpkg-perl.
(Reading database ... 38475 files and directories currently installed.)
Preparing to unpack .../0-libdpkg-perl_1.18.25_all.deb ...
Unpacking libdpkg-perl (1.18.25) ...
Selecting previously unselected package dpkg-dev.
Preparing to unpack .../1-dpkg-dev_1.18.25_all.deb ...
Unpacking dpkg-dev (1.18.25) ...
Selecting previously unselected package libfakeroot:amd64.
Preparing to unpack .../2-libfakeroot_1.21-3.1_amd64.deb ...
Unpacking libfakeroot:amd64 (1.21-3.1) ...
Selecting previously unselected package fakeroot.
Preparing to unpack .../3-fakeroot_1.21-3.1_amd64.deb ...
Unpacking fakeroot (1.21-3.1) ...
Selecting previously unselected package libalgorithm-diff-perl.
Preparing to unpack .../4-libalgorithm-diff-perl_1.19.03-1_all.deb ...
Unpacking libalgorithm-diff-perl (1.19.03-1) ...
Selecting previously unselected package libalgorithm-diff-xs-perl.
Preparing to unpack .../5-libalgorithm-diff-xs-perl_0.04-4+b2_amd64.deb ...Unpacking libalgorithm-diff-xs-perl (0.04-4+b2) ...
Selecting previously unselected package libalgorithm-merge-perl.
Preparing to unpack .../6-libalgorithm-merge-perl_0.08-3_all.deb ...
Unpacking libalgorithm-merge-perl (0.08-3) ...
Selecting previously unselected package libfile-fcntllock-perl.
Preparing to unpack .../7-libfile-fcntllock-perl_0.22-3+b2_amd64.deb ...
Unpacking libfile-fcntllock-perl (0.22-3+b2) ...
Selecting previously unselected package manpages-dev.
Preparing to unpack .../8-manpages-dev_4.10-2_all.deb ...
Unpacking manpages-dev (4.10-2) ...
Setting up libdpkg-perl (1.18.25) ...
Setting up libfile-fcntllock-perl (0.22-3+b2) ...
Setting up dpkg-dev (1.18.25) ...
Processing triggers for libc-bin (2.27-6) ...
Setting up libfakeroot:amd64 (1.21-3.1) ...
Setting up libalgorithm-diff-perl (1.19.03-1) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up manpages-dev (4.10-2) ...
Setting up fakeroot (1.21-3.1) ...
update-alternatives: using /usr/bin/fakeroot-sysv to provide /usr/bin/fakeroot (fakeroot) in auto mode
Setting up libalgorithm-merge-perl (0.08-3) ...
Setting up libalgorithm-diff-xs-perl (0.04-4+b2) ...
Processing triggers for libc-bin (2.27-6) ...
[master 77f42a4] committing changes in /etc after apt run
13 files changed, 28 insertions(+)
create mode 120000 alternatives/faked.1.gz
create mode 120000 alternatives/faked.es.1.gz
create mode 120000 alternatives/faked.fr.1.gz
create mode 120000 alternatives/faked.sv.1.gz
create mode 120000 alternatives/fakeroot
create mode 120000 alternatives/fakeroot.1.gz
create mode 120000 alternatives/fakeroot.es.1.gz
create mode 120000 alternatives/fakeroot.fr.1.gz
create mode 120000 alternatives/fakeroot.sv.1.gz
create mode 100644 dpkg/shlibs.default
create mode 100644 dpkg/shlibs.override
create mode 100644 ld.so.conf.d/fakeroot-x86_64-linux-gnu.conf

sudo aptitude -f install build-essential
The following NEW packages will be installed:
build-essential g++{a} g++-6{a} libc-dev-bin{ab}
libc6-dev{ab} libstdc++-6-dev{a} linux-libc-dev{a}
0 packages upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 12.6 MB of archives. After unpacking 60.9 MB will be used.
The following packages have unmet dependencies:
libc6-dev : Depends: libc6 (= 2.24-11+deb9u4) but 2.27-6 is installed
libc-dev-bin : Depends: libc6 (< 2.25) but 2.27-6 is installed
The following actions will resolve these dependencies:

Keep the following packages at their current version:
1) build-essential [Not Installed]
2) g++ [Not Installed]
3) g++-6 [Not Installed]
4) libc-dev-bin [Not Installed]
5) libc6-dev [Not Installed]
6) libstdc++-6-dev [Not Installed]



Accept this solution? [Y/n/q/?]
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.


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 haverequested 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:6.3) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Still the same result.

In the meantime I upgraded to Debian v9.12.

apt --dry-run install libc6=2.24-11+deb9u4
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  glibc-doc locales
The following packages will be REMOVED:
  libc-bin locales sudo
The following packages will be DOWNGRADED:
  libc6
WARNING: The following essential packages will be removed.
This should NOT be done unless you know exactly what you are doing!
  libc-bin
0 upgraded, 0 newly installed, 1 downgraded, 3 to remove and 0 not upgraded.
Remv locales [2.27-6]
Remv libc-bin [2.27-6]
Remv sudo [1.8.23-2]
Inst libc6 [2.27-6] (2.24-11+deb9u4 Debian:9.12/oldstable [amd64])
Conf libc6 (2.24-11+deb9u4 Debian:9.12/oldstable [amd64])

May I try apt --dry-run install libc6=2.24-11+deb9u4 ?

How can I fix the unmet dependencies?

klor
  • 304
  • 4
  • 8
  • 24

5 Answers5

7

Your problem here is that at some point in time, you installed a package from a source which contained a newer libc6, and that version of libc6 got installed. Now your packages are broken, since the libc6-dev package has a version of 2.24-11+deb9u4, but the libc6 package is at 2.27-6. This is probably because of the buster repository you mentioned.

The big problem here is that since buster is a debian version, if you had it in your sources for a long enough time, many packages might have been installed to your system. If you really had it only for installing mc, then the solution might be simpler.

Here is what you can do.

Upgrade your system to buster. This might not be a good solution for you, but if you replace your sources to buster, and do a dist-upgrade, everything should be well. Buster is, after all, a stable release. Still, you might want to think about it, as it is a complete system upgrade, and depending on what your system has installed, this might break the services you provide.

Downgrade your libc6 package. This may very well break your system, so be careful. Usually it is a bad idea to do this, unless you know what you're doing. Do read this whole text, and do not copy the commands blindly.

You might have upgraded other packages as well, since I don't know for how long the buster source had been active on your computer. First, you need to install the proper libc6 package, of which you need version 2.24-11+deb9u4 (according the output in your post). So you need to do the following.

Issue the

apt --dry-run install libc6=2.24-11+deb9u4

command. In the command output, you will see something like this:

WARNING: The following essential packages will be removed.
This should NOT be done unless you know exactly what you are doing!
  e2fsprogs libext2fs2 (due to e2fsprogs) libc-bin

The list of packages may wary, but for every one of them, you need to check the available version with apt-cache policy. You need the one with the greatest version number, which isn't locally installed. Record the version numbers and request the packages with that exact version number for install. You should add the --dry-run switch to the apt command, since the packages might break others in turn (this is highly unlikely, but it's better to be sure). You will probably encounter libext2fs2, which doesn't exist in Stretch. You may safely ignore that one, but if you encounter other packages which cannot be downgraded, you should record them, and look them up later. Usually, it is safe to let apt handle the removal of those.

After you got all the version numbers, give all packages to apt, requesting the version numbers you recorded, so you'll end up a long(ish) list of packages, like this (your list might be longer, depending on how many packages you installed from the Buster repository):

 apt --dry-run install e2fslibs=1.43.4-2+deb9u1 \
    e2fsprogs=1.43.4-2+deb9u1\
    libc-bin=2.24-11+deb9u4 \
    libc6=2.24-11+deb9u4

If you don't see any "essential packages will be removed" message in the output, you can safely issue the command without the --dry-run switch, and your system will not have any broken packages. If you do see that message, you need to include those packages in your command as well. Iterate until the command doesn't try to remove any essential packages. Note, however, that a few packages will be uninstalled, you might want to manually reinstall those if needed (but at that point, (re)installing should not pose any kind of problem or broken packages).

And this is why using different versions of repositories on a system is a bad idea.

Lacek
  • 6,585
  • 22
  • 28
  • Thanks! I was also thinking on "upgrading system to buster". Likely this will solve the problem. I will try it later, as currently the server is used in production. – klor Nov 28 '19 at 14:32
3

I had a similar issue.I resolve it by doing this:

Before starting,if you don't have aptitude, you can install it by following these instructions:aptitude documentation

If you have it already,you can move on. First you need to run:

sudo aptitude install g++

It will be ask this: Accept this solution? [Y/n/q/?] You must select "n".

It will suggest you to downgrade the package,and it will be ask this: Accept this solution? [Y/n/q/?]This time select "Y".

It will downgrade the package. After it is done,you can now install build-essential by doing this:

sudo aptitude -f install build-essential

It will be ask this: Accept this solution? [Y/n/q/?] You must select "Y".

It will install it.After it is done,you can run this command to check it:

sudo aptitude search build-essential

if you see this line in the result:

i build-essential - Informational list of build-essential pack

it means that the installation was successful,but if you don't see it then you have look for another solution in order to resolve it.

fleuro75
  • 31
  • 1
1

Finally I got help in another forum: https://serverfault.com/a/1004951/302842

This was the solution to downgrade the problematic packages:

apt install libc6/stretch libc6-dev/stretch libc-dev-bin/stretch libc-bin/stretch locales/stretch sudo/stretch

The downgrade was successful!

klor
  • 304
  • 4
  • 8
  • 24
1

You can try to clean all the cache data and install the dependencies manually. Then try to install the package build-essential

$ sudo apt-get clean
$ sudo apt update
$ sudo apt upgrade
$ sudo apt install libc6-dev g++
$ sudo apt install build-essential
ginerama
  • 216
  • 1
  • 7
0

Manifest for installing rust and build-essentials on Ubuntu 20.04.03:

rustup self uninstall
apt-get update
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe"
apt-get -u dist-upgrade
apt install aptitude 
sudo aptitude install libc6=2.31-0ubuntu9
sudo aptitude install build-essential
apt-get update
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y
rustup toolchain install nightly --allow-downgrade --profile minimal --component clippy
rustup default stable
rustup update nightly
rustup update stable
rustup target add wasm32-unknown-unknown --toolchain nightly
sudo apt install -y cmake pkg-config libssl-dev git gcc build-essential clang libclang-dev
rustc --version
source $HOME/.cargo/env

No tested on me: Fast Installation: Install all the required dependencies with a single command. (Be patient, this can take up to 30 minutes)

curl https://getsubstrate.io -sSf | bash -s -- --fast

Finally step test:

https://doc.rust-lang.org/cargo/getting-started/first-steps.html

tripleee
  • 1,324
  • 3
  • 14
  • 24