Unable to install R base; unmet dependencies on Ubuntu 18.04

12,065

I became convinced, after following the chain of fails on a number of the pathways, — "going down the rabbit hole", as suggested by @user535733 — that somehow two different sources appeared to have crept onto my system, each individually providing a consistent complete set of packages, but across the both mutually incompatible. An instance of that was finding gcc-8-base referring to both 8.3.0-6ubuntu1~18.04 and 8-20180414-1ubuntu2, but there were others, eventually found to be too many to resolve one at a time.

So I removed and restored the default repositories, as in, e.g., How do I restore the default repositories? through moving /etc/apt/sources.list to some safe temporary place [to be discarded later after everything was seen to work], touch-ing to create a new empty version, and then using software-properties-gtk to provide a fresh set of Ubuntu Software sources, and Updates (security and updates channels). Closed that so the system updated, and then in a terminal I ran

$ sudo apt update && sudo apt upgrade
$ sudo apt install r-base # Works cleanly!

(Many thanks to everyone who helped, but most of all to @user535733)

Share:
12,065

Related videos on Youtube

Danny Quah
Author by

Danny Quah

I am Dean and Li Ka Shing Professor in Economics, Lee Kuan Yew School of Public Policy, the National University of Singapore. I work on economic principles for world order and on empirics for a shifting global economy.

Updated on September 18, 2022

Comments

  • Danny Quah
    Danny Quah over 1 year

    I am trying to install R on an Ubuntu 18.04 machine and am encountering an "unmet dependencies" problem. However, I am unable to determine where I can go or what I need to fix on my system to overcome this. Any help would be greatly appreciated.

    I am running Ubuntu 18.04.2 LTS (with 16Gb RAM and 500Gb hard disk), using just the standard bionic repositories; the only PPA i've added is that for libreoffice. To see what's there, the output to sudo apt update is

    Ign:1 http://dl.google.com/linux/chrome-remote-desktop/deb stable InRelease
    Ign:2 http://dl.google.com/linux/chrome/deb stable InRelease   
    Hit:3 http://dl.google.com/linux/chrome-remote-desktop/deb stable Release
    Hit:4 http://dl.google.com/linux/chrome/deb stable Release                 
    Get:7 https://desktop-download.mendeley.com/download/apt stable InRelease [2,456 B]
    Get:8 https://typora.io/linux ./ InRelease [758 B]                         
    Hit:9 http://repository.spotify.com stable InRelease                       
    Hit:10 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/ InRelease
    Hit:11 http://ppa.launchpad.net/libreoffice/ppa/ubuntu bionic InRelease    
    Hit:12 http://sg.archive.ubuntu.com/ubuntu bionic InRelease                
    Hit:13 http://sg.archive.ubuntu.com/ubuntu bionic-backports InRelease
    Get:14 http://sg.archive.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
    Fetched 91.9 kB in 3s (26.5 kB/s)    
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    All packages are up to date.
    

    (I try to keep things in sync as much as possible and run sudo apt update && sudo apt upgrade at least once every two days.)

    When I attempt to install the first of R's components r-base (via sudo apt install r-base) I get the following unmet dependencies:

    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:
     r-base : Depends: r-base-core (>= 3.4.4-1ubuntu1) but it is not going to be installed
              Depends: r-recommended (= 3.4.4-1ubuntu1) but it is not going to be installed
              Recommends: r-base-html but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.
    

    Running software-properties-gtk, I see that all repositories are enabled. Running sudo apt-get clean and sudo apt-get autoclean proceeds to completion with no error messages. When I execute

    $ sudo apt-get -f install
    $ sudo dpkg --configure -a
    $ sudo apt-get -f install
    

    the output is

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

    so there seems to be no held or conflicted or broken packages on my system. I have also executed sudo apt --fix-broken install, but again, as above, my system seems to have no held or broken packages.

    Running sudo apt-get dist-upgrade shows

    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.
    

    I'm happy to try anything else someone might want to suggest to see if the fault remains on my system.

    Next I add

    deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/
    

    to my /etc/apt/sources.list and run

    $ sudo apt update
    $ sudo apt install r-base
    

    Still no joy; the output is now (omitting repeats from above)

    The following packages have unmet dependencies:
     r-base : Depends: r-base-core (>= 3.6.0-2bionic) but it is not going to be installed
              Depends: r-recommended (= 3.6.0-2bionic) but it is not going to be installed
              Recommends: r-base-html but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.
    

    (but at least I've moved from 3.4.4-1ubuntu1 to 3.6.0-2bionic.) Repeating the sudo apt-get -f install ; sudo dpkg --configure -a; sudo apt-get -f install sequence above continues to show

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

    so again there seems to be no held or conflicted packages otherwise.

    The output from apt-cache policy r-base is:

      Installed: (none)
      Candidate: 3.6.0-2bionic
      Version table:
         3.6.0-2bionic 500
            500 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/ Packages
         3.6.0-1bionic 500
            500 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/ Packages
         3.5.3-1bionic 500
            500 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/ Packages
         3.5.2-1bionic 500
            500 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/ Packages
         3.5.1-2bionic 500
            500 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/ Packages
         3.5.1-1bionic 500
            500 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/ Packages
         3.5.0-1bionic 500
            500 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/ Packages
         3.4.4-1ubuntu1 500
            500 http://sg.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
            500 http://sg.archive.ubuntu.com/ubuntu bionic/universe i386 Packages
    

    I'm not sure, however, where to go dig further or what files to adjust based on this output.

    Are there locations I need to add to my /etc/apt/sources.list to put in place the dependencies on r-base-core and r-recommended? Where else do I need to go to get them? The linux installation page

    https://cran.ma.imperial.ac.uk/bin/linux/ubuntu/README.html
    

    does not suggest to me anything further to add to my /etc/apt/sources.list. Google returns a whole bunch of other things including marutter's PPA and I've experimented with adding those into my sources, but none has allowed me to install to completion. [Yes, when I've removed them, I've made sure to run through clean and autoclean each time, as above.]

    To be clear, I am not obsessed about having the absolutely latest version of R/ I'd be happy with anything else slightly out-dated too, but I don't see any hint on the linux installation page for R what I might adjust.

    (On my other machines, GalliumOS 2.1 and GalliumOS 3.0, I have installed R and RStudio, no issues. )

    Any help would be greatly appreciated.

    (This problem has now been solved as described below; I had two slightly inconsistent versions of packages. I ended up removing both and re-installed just one.)

    • user535733
      user535733 almost 5 years
      Please edit your question to show us the complete output of sudo apt update. This is one easy way to see all your sources in one print.
    • Danny Quah
      Danny Quah almost 5 years
      @user535733 - thanks. Have added now that output you suggested.
    • Danny Quah
      Danny Quah almost 5 years
      @N0rbert - 'universe' distribution component is already enabled for all sources.
    • N0rbert
      N0rbert almost 5 years
      @DannyQuah Then try to get newest dependencies with sudo apt-get dist-upgrade and add error output to the question (if any).
    • Danny Quah
      Danny Quah almost 5 years
      @Norbert - running sudo apt-get dist-upgrade shows [09:01 PM xbook ...tc/apt]$ sudo apt-get dist-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.
    • user535733
      user535733 almost 5 years
      I suggest using apt-cache policy on the troublesome packages, and following that trail until you find the version conflict. It's slow, but sure. Looks to me like you don't have a missing source; looks like you have a version conflict somewhere.
    • Danny Quah
      Danny Quah almost 5 years
      @user535733 - apt-cache policy sounds hopeful; I'd tried it previously but wasn't sure how to follow up with it. I still don't know whether it's R end or my system that needs to be augmented, so any help would be appreciated. Will edit my question to include this.
    • user535733
      user535733 almost 5 years
      Start with apt-cache policy r-base, and post the complete output into your question.
    • user535733
      user535733 almost 5 years
      Next step is to try installing each dependency, and figuring out which don't work and looking into their dependencies. There's a break somewhere. This crawling down the chain of dependencies is sometimes called "going down the rabbit-hole", Try sudo apt install r-base-core r-recommended --simulate and see which one fails. Then let's look at the failure.
    • Danny Quah
      Danny Quah almost 5 years
      @user535733 - thanks for the suggestion. One such pursuit leads to The following packages have unmet dependencies: libquadmath0 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.3.0-6ubuntu1~18.04 is to be installed but when I query for gcc-8-base what I'm told is gcc-8-base is already the newest version (8.3.0-6ubuntu1~18.04). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. I'm told this is where the buck stops but it shouldn't as I've already got the newest version?
    • user535733
      user535733 almost 5 years
      Bingo! Now run apt-cache policy gcc-8-base to see which sources the two different versions are coming from.
    • Danny Quah
      Danny Quah almost 5 years
      @user535733 When I run apt-cache policy gcc-8-base, I get gcc-8-base: Installed: 8.3.0-6ubuntu1~18.04 Candidate: 8.3.0-6ubuntu1~18.04 Version table: *** 8.3.0-6ubuntu1~18.04 100 100 /var/lib/dpkg/status 8-20180414-1ubuntu2 500 500 http://sg.archive.ubuntu.com/ubuntu bionic/main amd64 Packages Grateful for how I go from here to what I do next?
    • user535733
      user535733 almost 5 years
      Here's what is happening: Two sets of sources each seem to be providing a complete set of packages. But those packages are incompatible (different versions). You must make the Solomon-like decision as to which version you want, and tell the system to use that version. There are two ways to do it: You can pin the version of gcc-8-base, or you can simply remove the source that provides the version you don't want.
    • user535733
      user535733 almost 5 years
      Safest practice is usually to remove the non-Ubuntu source, then remove all packages already installed from that source (if any), then sudo apt update to refresh your package database (since your sources have changed). This will solve the gcc-8-base problem - there might be others we don't know about yet. You had a different problem before adding the non-Ubuntu cran repo, and we haven't looked at that yet. It's your system, so it's entirely your decision.
    • Danny Quah
      Danny Quah almost 5 years
      @user535733 Thanks for the invaluable help. Trying to implement now your suggestion by taking out the non-Ubuntu source and following through. Still in progress.
    • user535733
      user535733 almost 5 years
      The ppa-purge tool can be very convenient for this kind of work.