0

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

3 Answers3

2

This may because of the source.lists file. I have met the same problem. As the official install method, you have to run the command as follows:

add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"

if you have add a various of repository, this may be the reason why you met this problem. Maybe you should edit your /etc/apt/source.lists and remove the other repository and just remain the only official repository.

bathyscapher
  • 117
  • 5
Zidea
  • 21
  • 2
    Sorry your answer is not clear. What does this mean? if you have add a various of repository , – David Mar 18 '22 at 14:58
  • 1
    Before I run into official installation method, I have run some other command such as add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran35/" (dd-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/" is the right command for my OS) . When I run the command apt install r-base It show the same error as yours.After I delete the wrong repository in source.lists and run the apt update ``apt install r-base. I found it can success install R – Zidea Mar 18 '22 at 18:52
1

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
0

Is it possible hat you are trying to install R on Ubuntu for ARM64? I was having the same problem when trying to install R on ubuntu on an arm64 machine. I did install R from source.

witek
  • 101