Home > OS >  How to install R on Ubuntu 21.10
How to install R on Ubuntu 21.10

Time:12-21

I just bought a new machine and made a fresh installation of Ubuntu 21.10 since I've read that the newer kernel works better with graphics drivers. I'm planning to update to the 22.04 LTS when it will be available. I didn't realize, however, that I might run into challenges with R.

There are plenty of questions here in SO on installing R on Ubuntu, but none seemed recent enough to address the Ubuntu version 21.10.

Ubuntu Packages For R - Full Instructions state that

As of May 19, 2021 the supported releases are

  • Hirsute Hippo (21.04, amd64 only)
  • Groovy Gorilla (20.10, amd64 only),
  • Focal Fossa (20.04; LTS and amd64 only),
  • Bionic Beaver (18.04; LTS), and
  • Xenial Xerus (16.04; LTS).

So, if I understand correctly, I have three options:

  1. Uninstall 21.10 and replace with 21.04
  2. Wait for support for 21.10
  3. Install R from source

Now, the question is, have I understood correctly, or could I use, for example, the 21.04 repository (hirsute-cran40/)?

CodePudding user response:

Apparently, it is ok to use a repository of older releases.

I was encouraged by Andre Wildeberg (thanks!) and added the 21.04 repository (hirsute-cran40/) into my /etc/apt/sources.list:

deb https://cloud.r-project.org/bin/linux/ubuntu hirsute-cran40/

What is missing from the CRAN instruction, is adding the relevant GPG key. I used the example by Lisa Tagliaferry from Digital Ocean, although it gives a deprecation warning:

$ https://www.digitalocean.com/community/tutorials/how-to-install-r-on-ubuntu-20-04
...
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
Executing: /tmp/apt-key-gpghome.cul0ddtmN1/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
gpg: key 51716619E084DAB9: public key "Michael Rutter <[email protected]>" imported
gpg: Total number processed: 1
gpg:               imported: 1

Then I installed the base R:

$ sudo apt-get update
$ sudo apt-get install r-base

and everything seems to be working fine.

CodePudding user response:

You need a newer signing key for that repo:

root:~#  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.MsSJzqgwfx/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
gpg: key 51716619E084DAB9: "Michael Rutter <[email protected]>" 1 new signature
gpg: failed to start agent '/usr/bin/gpg-agent': No such file or directory
gpg: can't connect to the agent: No such file or directory
gpg: Total number processed: 1
gpg:         new signatures: 1
root:~# apt update
Get:1 https://cloud.r-project.org/bin/linux/ubuntu hirsute-cran40/ InRelease [3628 B]
Get:2 http://security.ubuntu.com/ubuntu impish-security InRelease [110 kB]                                                                
Hit:3 http://archive.ubuntu.com/ubuntu impish InRelease                                                  
Get:4 http://archive.ubuntu.com/ubuntu impish-updates InRelease [110 kB]
Get:5 http://archive.ubuntu.com/ubuntu impish-backports InRelease [101 kB]
Fetched 325 kB in 1s (422 kB/s)  
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
1 package can be upgraded. Run 'apt list --upgradable' to see it.
root:# 

One you have that, impish works fine. That said, hirsute binaries should work too (or even focal binaries, as one does with the 5000 r-cran-* binaries the 'cran2deb4ubuntu' repo for the LTS release).

  • Related