No se puede instalar paquete build-essential en Ubuntu 20.04

Últimamente he estado trabajando principamente en una máquina con Windows 10. utilizando WSL para todo lo relacionado con Linux. Tengo ubuntu 20.04 instalado en WSL, para trabajar con algunas aplicaciones en Java y Python, pero recientemente tuve la necesidad de instalar build-essential pero no me fue posible:

$ 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.

Nota: si tienes exactamente el mismo problema y tienes un poco de prisa, ve al final del artículo para ver los comandos que tienes que ejecutar para poder instalar build-essential.

No se podía cumplir con dos dependencias: libc6-dev y g++. Muy extraño, nunca había tenido este problema antes (build-essential esw un paquete bastante común para instalaciones Ubuntu), no estoy seguro si esto afecta también a una intalación “nativa” de Ubuntu (o que no sea con WSL), pero es probable que si.

Intenté instalar 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.

Bien, libc6-dev depende de libc6-dev, pero parece que las versiones no coinciden: tenemos libc6 versión 2.31-0ubuntu9.3 pero libc6-dev depende en la versión anterior 2.31-0ubuntu9.2.

Podemos instalar una versión previa de libc6, primero revisamos si está disponible. La opción -a del comando show de apt nos muestra todas las versiones disponibles de un paquete:

$ apt show -a libc6
Package: libc6
Version: 2.31-0ubuntu9.3
Status: install ok installed
Priority: required
Section: libs
Source: glibc
Maintainer: Ubuntu Developers 
Original-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.

Tenemos las versiones 2.31-0ubuntu9.3, 2.31-0ubuntu9.2 y 2.31-0ubuntu9. Instalemos la versión requerida por 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) ...

Ahora intentemos nuevamente instalar build-essential:

$ 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) ...

¡Hecho!

En resumen: se tiene que regresar libc6 a la versión anterior 2.31-0ubuntu9.2, entonces ya se puede instalar build-essential y sus dependencias:

$ sudo apt install libc6=2.31-0ubuntu9.2
$ sudo apt install build-essential

Sé el primero en comentar

Dejar una contestacion

Tu dirección de correo electrónico no será publicada.


*