Score:3

How to install R 4.0 on Ubuntu 18.04 when 'r-base' has no installation candidate

at flag

I was following this instruction for installing R 4.0 in Ubuntu 18.04

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

However I get this error message:

Reading package lists... Done
Building dependency tree
Reading state information... Done
Package r-base is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  r-base-core r-doc-info r-doc-html r-base-html r-base-core:i386

E: Package 'r-base' has no installation candidate

I'm using this version of Ubuntu:

$ uname -a
Linux ip-172-31-28-209 5.4.0-1059-aws #62~18.04.1-Ubuntu SMP Fri Oct 22 21:51:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -cs
bionic

How can I resolve the issue?


Update

$ sudo apt-cache policy r-base
r-base:
  Installed: (none)
  Candidate: (none)
  Version table:
     4.1.2-1.1804.0 -1
         -1 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ Packages
     4.1.1-1.1804.0 -1
         -1 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ Packages
     4.1.0-1.1804.0 -1
         -1 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ Packages
     4.0.5-1.1804.0 -1
         -1 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ Packages
     4.0.4-1.1804.0 -1
         -1 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ Packages
     4.0.3-1.1804.0 -1
         -1 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ Packages
     4.0.2-1.1804.0 -1
         -1 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ Packages
     4.0.1-1.1804.0 -1
         -1 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ Packages
     4.0.0-1.1804.0 -1
         -1 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ Packages
     3.4.4-1ubuntu1 -1
         -1 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages

Update 2

$ sudo apt install r-base=4.1.2-1.1804.0
Reading package lists... Done
Building dependency tree
Reading state information... Done
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 (>= 4.1.2-1.1804.0) but it is not installable
          Depends: r-recommended (= 4.1.2-1.1804.0) but it is not installable
          Recommends: r-base-html but it is not installable
          Recommends: r-doc-html but it is not installable
E: Unable to correct problems, you have held broken packages.
user.dz avatar
ng flag
Could you add the output of `apt-cache policy r-base`
scamander avatar
at flag
@user.dz see my update.
abu-ahmed al-khatiri avatar
in flag
try to check `gpg --list-keys E298A3A825C0D65DFD57CBB651716619E084DAB9`
user.dz avatar
ng flag
@scamander, it seems like you have an apt package "pinning" active with "-1" which holding you from installing it. Have you set it yourself? Try force a version installation: `sudo apt install r-base=4.1.2-1.1804.0`
scamander avatar
at flag
@user.dz how can I disable `-1` ? I didn't set it myself. I tried force as you suggested. Still doesn't work. See my update.
scamander avatar
at flag
@abu-ahmedal-khatiri Doesn't work. I get `gpg: error reading key: No public key`
Score:2
at flag

Following suggestion by @user.dz, I ended up manually editing /etc/apt/preferences and replacing pin priority from -1 to 500

Package: *
Pin: release a=bionic*
Pin-Priority: 500
Score:1
in flag

The Problem is :

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
  Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
  Executing: /tmp/apt-key-gpghome.D7jTjWc4gW/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
  gpg: key 51716619E084DAB9: "Michael Rutter <marutter@gmail.com>" 1 new signature
  gpg: Total number processed: 1
  gpg:         new signatures: 1     

When you run apt-key the keyserver is deprecated on /tmp/ like my case. The Ubuntu archives on CRAN are signed with the key of Michael Rutter marutter@gmail.com with key ID 0x51716619e084dab9. To add the key to your system with one command use

Recommended method :

$ wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
$ sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
$ sudo apt update
$ sudo apt install --no-install-recommends r-base     

Hope this helps.

Related

user.dz avatar
ng flag
While pinning works for OP, this could be the root cause of the issue. I may check it later in a vm.
abu-ahmed al-khatiri avatar
in flag
@user.dz when OP try to install `r-base` aptitude try to install `r-base v4.1` has no candidate as 'apt-cache' said. which holding the package if it use `apt-key`, i recommended to use secure apt in `trusted.gpg`, and the candidate should be appears. edit the preference is shortcut way and that's great idea.
user.dz avatar
ng flag
I just tested in 18.04 same instructions OP used, however I get `r-base` with priority of `500`, no warning when adding the key. So i couldn't reproduce the test case.
Score:-1
us flag

Given you get the message:

However the following packages replace it:
  r-base-core r-doc-info r-doc-html r-base-html r-base-core:i386

I am going to say perhaps r-base-core.

scamander avatar
at flag
I tried that but doesn't work as well.
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.