Ubuntu – R 3.5.0 not working on Ubuntu 18.04

18.04gnomer

I just installed Ubuntu 18.04 on my testbed laptop. Total fresh install (chose the 'minimal' option). The first two things I did were install R 3.5 and R Studio 1.1.453. If I open up a fresh install of R and just let it sit idle for 30 minutes or so I eventually get the error "Error: Unable to establish connection with R session".

At this point in time I can't do anything in R Studio and I have to xkill it and reload everything to continue programming. An internet search reveals that this issue has been popping up repeatedly since people have been installing R/R Studio on Ubuntu machines that use GNOME. Am not sure if GNOME is the root cause but it's interesting.

Anybody solved this? Or maybe you run R 3.5 fine on Ubuntu 18.04 without issue. Please let me know. I can only run for 30 minutes or so before this issue brings my system down. And my system is a fresh install of Bionic Beaver with just R on it. Weird.

—— and for those wondering ——

installation for R was via

sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/"
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
sudo apt-get update
sudo apt-get install r-base r-base-dev

and R Studio was installed via this link through the Ubuntu software center
https://download1.rstudio.org/rstudio-xenial-1.1.453-amd64.deb

and it is speculated that the preview release of R Studio may fix this (TBD)
https://s3.amazonaws.com/rstudio-ide-build/desktop/trusty/amd64/rstudio-1.2.792-amd64.deb

Best Answer

Currently CRAN mirror provides R 3.6 by default.

To get R 3.5 on Ubuntu 18.04 LTS we need to add CRAN repository with:

sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/"
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
sudo apt-get update

and then adjust APT to the highest priority of R 3.5.x versions for the CRAN repository with long single command:

cat <<EOF | sudo tee /etc/apt/preferences.d/pin-r35
Package: r-*
Pin: release a=bionic-cran35
Pin: version 3.5*
Pin-Priority: 800

Package: r-cran-nlme
Pin: release a=bionic-cran35
Pin: version 3.1.139-1bionic0
Pin-Priority: 800

Package: r-cran-cluster
Pin: release a=bionic-cran35
Pin: version 2.0.8-1bionic0
Pin-Priority: 800
EOF

Then install R 3.5 with the command below:

sudo apt-get install r-base r-base-dev

And finally check that R version is 3.5:

$ R

R version 3.5.3 (2019-03-11) -- "Great Truth"

Notes:

  1. I have checked this method on clean Ubuntu 18.04 LTS VM with two essential R packages installed - r-base and r-base-dev (and their dependencies).
  2. If you want to revert to R 3.6 - then simply remove pin/lock file with sudo rm /etc/apt/preferences.d/pin-r35 and run sudo apt-get dist-upgrade to get the newest dependencies.
  3. For Ubuntu 16.04 LTS the method is very similar - see my other answer.
Related Question