Installing packages in Ubuntu R: after editing my /etc/apt/sources.list file, apt-get update doesn't work anymore

I decided to install Ubuntu on my home laptop, and the second package I installed (after Chrome) was of course R :grinning: I followed this guideline

which has the added bonus of showing how to link R vs the OpenBLAS! (this accelerates linear algebra operations). However, when I arrived at the package installation part, it didn't work. I went to CRAN:

https://cran.r-project.org/bin/linux/ubuntu/

According to the CRAN guideline, since apt-get gets me R 3.4.4 under Ubuntu 18.04 (LTS), I figured that I should comment the last line of my /etc/apt/sources.list file

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

(since it was trying to get me the 3.5 package sources) and I added line

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

Now, I can install R packages! :partying_face: However, it looks like I broke apt-get update :frowning_face:

andrea@...~$ sudo apt-get update
[sudo] password for andrea: 
Ign:1 http://dl.google.com/linux/chrome/deb stable InRelease
Get:2 http://security.ubuntu.com/ubuntu bionic-security InRelease [83,2 kB]                         
Hit:3 http://it.archive.ubuntu.com/ubuntu bionic InRelease                                          
Hit:4 http://dl.google.com/linux/chrome/deb stable Release                                          
Hit:5 http://it.archive.ubuntu.com/ubuntu bionic-updates InRelease                                  
Hit:6 https://download.docker.com/linux/ubuntu bionic InRelease                                     
Hit:7 http://it.archive.ubuntu.com/ubuntu bionic-backports InRelease                                
Get:8 https://cloud.r-project.org/bin/linux/ubuntu xenial/ InRelease [3.590 B]                      
Get:10 http://security.ubuntu.com/ubuntu bionic-security/main i386 Packages [165 kB]
Err:8 https://cloud.r-project.org/bin/linux/ubuntu xenial/ InRelease       
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 51716619E084DAB9
Get:11 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [208 kB]
Get:12 http://security.ubuntu.com/ubuntu bionic-security/main Translation-en [81,8 kB]
Reading package lists... Done                                     
W: GPG error: https://cloud.r-project.org/bin/linux/ubuntu xenial/ InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 51716619E084DAB9
E: The repository 'https://cloud.r-project.org/bin/linux/ubuntu xenial/ InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details

What's happening? How do I fix that?
.

I'm not running Ubuntu, but it looks like it's a security issue that you'll have to configure for your machine.

Couple possibly relevant threads:

1 Like

Wow, thanks! How did you find this thread? I could only find

which however didn't cut the mustard. I'll try the fix reported in your thread and let you know. Thanks!

I think I just googled

see apt-secure(8) manpage for repository creation

but, Google is different for everyone, these days. ¯\(°_o)/¯

1 Like

That's actually a great suggestion! Sometimes I forget that the first thing to google for is exactly the error message, and I twist my brain trying to describe the error in words, while I should just copy the error message verbatim and see if I can find something. Must :hammer: this in my mind...

2 Likes

I found the solution. Basically, one should not modify manually the /etc/apt/sources.list file (even if the CRAN instructions seem to suggest this), but rather follow the approach explained here

where first of all a trusted key is added to apt-key, so that apt-get will trust the CRAN repositories. The only line to be modified in the Digital Ocean guide above, is the line concerning the repository itself:

sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/'

may not work, because the r-base version which gets installed by default on Ubunut 18.04 is R 3.4.4 (at least, so it does on my laptop). If after using the above instruction you find out that you cannot install packages in R (because they're not the right version) you need instead this line:

sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu xenial/'

Apart from that, the D.O. guide is :ok_hand: I hope these instructions will be of help for other R users in Ubuntu!

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.