Score:0

Problems installing latest version of R in ubuntu 20.04 LTS

nl flag

I've been trying to install R 4.1 on ubuntu and each time I get the same error

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

I looked it up and it appears to be a common problem and I tried all the solutions suggested - Uninstalled and reinstalled R, deleted and recreated a new /etc/apt/sources.list file, restored default repositories, made sure focal-cran40 is on the sources.list, updated and upgraded everything. But i'm still having the same problem. This is my code

sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/'
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo apt update && sudo apt upgrade
sudo apt install r-base

Here is the output of apt-cache policy

sudo apt-cache policy r-base r-base-dev r-base-core r-recommended
r-base:
  Installed: (none)
  Candidate: 4.1.2-1.2004.0
  Version table:
     4.1.2-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.1.1-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.1.0-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.5-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.4-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.3-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.2-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.1-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.0-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
r-base-dev:
  Installed: (none)
  Candidate: 4.1.2-1.2004.0
  Version table:
     4.1.2-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.1.1-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.1.0-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.5-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.4-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.3-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.2-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.1-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.0-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
r-base-core:
  Installed: 3.6.3-2
  Candidate: 3.6.3-2
  Version table:
 *** 3.6.3-2 100
        100 /var/lib/dpkg/status
r-recommended:
  Installed: (none)
  Candidate: 4.1.2-1.2004.0
  Version table:
     4.1.2-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.1.1-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.1.0-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.5-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.4-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.3-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.2-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.1-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.0-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
N0rbert avatar
zw flag
Can't reproduce on fresh 20.04 LTS VM. Please add output of `apt-cache policy r-base r-base-dev r-base-core r-recommended` to the question by [editing it](https://askubuntu.com/posts/1373827/edit).
Apoorva Babu avatar
nl flag
I added the apt-cache policy. Any solutions to fix it ?
N0rbert avatar
zw flag
Does this answer your question? [How do I enable the "Universe" repository?](https://askubuntu.com/questions/148638/how-do-i-enable-the-universe-repository) You have incorrect output of r-base-core (correct will include universe as orogin for https://packages.ubuntu.com/focal/r-base-core ).
karel avatar
sa flag
Does this answer your question? [How do I resolve unmet dependencies after adding a PPA?](https://askubuntu.com/questions/140246/how-do-i-resolve-unmet-dependencies-after-adding-a-ppa)
Score:0
us flag

I was having the same issue. It looks like the version of the default libraries are not compatible, specially r-base-core is only available in version 3.6.3-2 (check using apt-cache show r-base-core)

Given that some libraries were not available in version 4.x, I decided to install version 3.6 using the following code and it worked:

apt install r-recommended=3.6.3-2 r-base=3.6.3-2 r-base-dev=3.6.3-2
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.