0

I am trying to install gcc (in order to install postGIS later), but i have the folowing problem (you can see in the picture). Can anyone help?

See terminal

Liso
  • 15,377
  • 3
  • 51
  • 80
  • Please avoid upload terminal screenshot, instead copy the output to the post. – Liso Mar 16 '19 at 12:08
  • run and post output from apt-cache policy gcc gcc-7 – doug Mar 16 '19 at 12:10
  • gcc-7 7.3.0-12 looks more like a Debian package than an Ubuntu one - have you added any non-Ubuntu repositories to your apt sources? – steeldriver Mar 16 '19 at 12:10
  • @doug gcc: Installed: (none) Candidate: 4:7.3.0-3ubuntu2 Version table: 4:7.3.0-3ubuntu2 500 500 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages gcc-7: Installed: (none) Candidate: 7.3.0-16ubuntu3 Version table: 7.3.0-16ubuntu3 500 500 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages – Laura A. Agalioti Mar 16 '19 at 12:12
  • Run sudo apt update before install, to update the package repository. – Soren A Mar 16 '19 at 12:14
  • @SorenA i get these: Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease Hit:2 http://security.ubuntu.com/ubuntu bionic-security InRelease Reading package lists... Done Building dependency tree
    Reading state information... Done 3 packages can be upgraded. Run 'apt list --upgradable' to see them.
    – Laura A. Agalioti Mar 16 '19 at 12:16
  • @LauraA.Agalioti great .. then run sudo apt upgradeto install those packages. And lastly, run sudo apt install gcc again. – Soren A Mar 16 '19 at 12:27
  • @SorenA i take the following: Reading package lists... Done Building dependency tree
    Reading state information... Done Calculating upgrade... Done The following packages were automatically installed and are no longer required: linux-headers-4.15.0-36 linux-headers-4.15.0-36-generic linux-image-4.15.0-36-generic linux-modules-4.15.0-36-generic linux-modules-extra-4.15.0-36-generic Use 'sudo apt autoremove' to remove them. The following packages have been kept back: curl libcurl4 libcurl4-openssl-dev 0 to upgrade, 0 to newly install, 0 to remove and 3 not to upgrade.
    – Laura A. Agalioti Mar 16 '19 at 12:29
  • @LauraA.Agalioti then run sudo apt full-upgrade – Soren A Mar 16 '19 at 12:34
  • Issue was likely you had disabled the Security & Updates repos as gcc in 18.04 is currently at 4:7.3.0-3ubuntu2.1 not 4:7.3.0-3ubuntu2 – doug Mar 18 '19 at 21:45

1 Answers1

1

You can get a list of actually held packages with:

dpkg --get-selections | grep hold

If there are none, or none look related, then it's probably something else. You can also try using the aptitude rather than apt-get to install your package:

sudo aptitude install <packagename>

Aptitude will try and find solutions which involve modifying other packages. It will also give you a detailed explanation of the problem and options for fixing it.

If you try Aptitude with -f, it will change its priorities and then you will obtain only those solutions which require removing/downgrading fewer packages. Here's the command:

sudo aptitude -f install <packagename>

Note: Assuming dpkg --get-selections | grep hold is empty, Aptitude is your best solution to resolve held packages.

Source URL: Unable to correct problems, you have held broken packages

Manu Mathur
  • 1,030