0

Hi I was wondering how to fix g++ and build essential. This is what it keeps saying:

Setting up g++ (4:8.2.0-1ubuntu1) ...
update-alternatives: error: /var/lib/dpkg/alternatives/c++ corrupt: invalid status
dpkg: error processing package g++ (--configure):
 installed g++ package post-installation script subprocess returned error exit status 2
dpkg: dependency problems prevent configuration of build-essential:
 build-essential depends on g++ (>= 4:7.3); however:
  Package g++ is not configured yet.

Now I can't install anything

$ sudo apt-get install g++
Reading package lists... Done
Building dependency tree       
Reading state information... Done
g++ is already the newest version (4:8.2.0-1ubuntu1).
The following packages were automatically installed and are no longer required:
  fprintd gir1.2-accountsservice-1.0 gir1.2-gck-1 gir1.2-gcr-3
  gir1.2-gdesktopenums-3.0 gir1.2-gdm-1.0 gir1.2-gnomebluetooth-1.0
  gir1.2-gnomedesktop-3.0 gir1.2-gweather-3.0 gir1.2-nm-1.0 gir1.2-nma-1.0
  gir1.2-rsvg-2.0 gir1.2-upowerglib-1.0 gjs glib-networking:i386
  gnome-control-center-faces gnome-shell-common gnome-todo-common libargon2-0
  libaspell15:i386 libatk-bridge2.0-0:i386 libatk1.0-0:i386 libatspi2.0-0:i386
  libboost-date-time1.65.1 libboost-locale1.65.1 libboost-thread1.65.1
  libbrotli1:i386 libcairo-gobject2:i386 libcamel-1.2-61 libcolord-gtk1
  libcolord2:i386 libcomerr2:i386 libdatrie1:i386 libdazzle-1.0-0
  libdns-export1100 libebook-1.2-19 libedata-cal-1.2-29 libenchant1c2a:i386
  libepoxy0:i386 libfprint0 libfribidi0:i386 libgdk-pixbuf2.0-0:i386 libgdm1
  libgjs0g libglvnd0:i386 libgnome-todo libgraphene-1.0-0 libgraphite2-3:i386
  libgudev-1.0-0:i386 libharfbuzz-icu0:i386 libharfbuzz0b:i386
  libhunspell-1.6-0:i386 libhyphen0:i386 libjson-glib-1.0-0:i386 liblouis14
  libmagickcore-6.q16-3 libmagickcore-6.q16-3-extra libmagickwand-6.q16-3
  libmozjs-60-0 libnotify4:i386 libpam-fprintd libpango-1.0-0:i386
  libpangocairo-1.0-0:i386 libpangoft2-1.0-0:i386 libpoppler73 libprocps6
  libproxy1v5:i386 libpsl5:i386 libraw16 librest-0.7-0:i386 libsecret-1-0:i386
  libsoup-gnome2.4-1:i386 libsoup2.4-1:i386 libspeexdsp1:i386 libstdc++-7-dev
  libsysmetrics1 libthai0:i386 libwebpdemux2:i386 libwoff1:i386 libxcb-res0
  libxkbcommon0:i386 linux-headers-4.15.0-44 linux-headers-4.15.0-44-generic
  linux-image-4.15.0-44-generic linux-modules-4.15.0-44-generic
  linux-modules-extra-4.15.0-44-generic mutter-common nplan
  python3-macaroonbakery python3-nacl python3-protobuf python3-pymacaroons
  python3-rfc3339 python3-tz switcheroo-control xwayland
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up g++ (4:8.2.0-1ubuntu1) ...
update-alternatives: error: /var/lib/dpkg/alternatives/c++ corrupt: invalid status
dpkg: error processing package g++ (--configure):
 installed g++ package post-installation script subprocess returned error exit status 2
dpkg: dependency problems prevent configuration of build-essential:
 build-essential depends on g++ (>= 4:7.3); however:
  Package g++ is not configured yet.

dpkg: error processing package build-essential (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
 g++
 build-essential
E: Sub-process /usr/bin/dpkg returned an error code (1)

dpkg: error processing package build-essential (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 g++
 build-essential
2
  • I'm seeing a failed install, but not anything indicating it didn't download. Can you use the edit button to add formatting and further clarify this? Commented Feb 12, 2019 at 1:55
  • Setting up g++ (4:8.2.0-1ubuntu1) ... update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode Setting up build-essential (12.5ubuntu2) ... Thnks it works
    – orion tree
    Commented Feb 12, 2019 at 15:12

1 Answer 1

0

This appears very similar to this. I've adapted the accepted answer here:

The alternatives entries are broken.

  1. You should remove them with:

    sudo update-alternatives --remove-all c++
    sudo rm -f /etc/alternatives/c++ /var/lib/dpkg/alternatives/c++
    

    If update-alternatives complains about corrupt files again, ignore it and just proceed to delete them with the next command.

  2. Reinstall dependencies with sudo apt-get -f install

  3. Then re-install their packages with:

    sudo apt-get install --reinstall c++
    

    This will restore the alternatives entries according to the packages available on your system.

  4. Proceed analogously for any further corrupted entries.

2
  • now its getting something about unmet dependes. But my computers slow or i would put the txt
    – orion tree
    Commented Feb 12, 2019 at 15:05
  • Try sudo apt-get -f install Commented Feb 12, 2019 at 23:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .