My setup
Below I report the details of the software I am running on my local machine.
Linux
This is the output of the lsb_release -a
command when I run it in my terminal.
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal
R
This is the output of the R --version
command when I run it in my terminal.
R version 4.0.4 (2021-02-15) -- "Lost Library Book"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
https://www.gnu.org/licenses/.
RStudio
I am running RStudio Version 1.4.1106.
The problem
Whenever I try to install a package with the install.packages()
function in RStudio, the console returns errors. This behaviour is consistent across packages, as I tried installing tidyverse, here, devtools, usethis, reticulate, etc.
The error output
Below is the output when I run install.packages("here")
and install.packages("tidyverse")
, but the same happens with any package.
The here package
Installing package into ‘/home/valerio/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/here_1.0.1.tar.gz'
Warning in install.packages :
URL 'https://cloud.r-project.org/src/contrib/here_1.0.1.tar.gz': status was 'Couldn't resolve host name'
Error in download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'https://cloud.r-project.org/src/contrib/here_1.0.1.tar.gz'
Warning in install.packages :
download of package ‘here’ failed
The tidyverse package
Warning in install.packages :
installation of package ‘tidyverse’ had non-zero exit status
My troubleshooting attempts
I have tried many things so far, but they were all unsuccessful.
- I followed the Linuxize's guide.
- I used the verbose version of the function
install.packages()
, specifying the arguments repos and dependencies. - I run both
sudo apt update
andsudo apt upgrade
in the terminal. - I also run
sudo apt install r-base-dev
. - I run
sudo apt-get install build-essential
too. - I used
sudo apt install
for libcurl4-openssl-dev, libssl-dev, and libxml2-dev. - Not to mention the
sudo apt-get install g++
. - I opened the console as a root with
sudo -i R
and try installing the packages from there. - I changed the primary CRAN repository from the RStudio's Global Options (Packages tab).
- I unticked the use secure download method for HTTP box from the RStudio's Global Options (Packages tab).
- I restarted RStudio at each step and/or closed it and re-opened it.
- I also tried installing packages from the RStudio's toolbar (Tools > Install Packages...).
I ended up in such a deep rabbit hole that I cannot even remember how many fixes I tried and in which combination.
I also tried using the code below:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
This did not solve the issues either.
Help, please!
Nothing worked thus far and I do not know what to do. I am by no means an expert Linux user and hope that someone in the community could help me with this nightmare.
Thanks, I look forward to hearing from you.
Best wishes,
Valerio