R 3.5.0 not working on Ubuntu 18.04

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


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.

I think that I did follow your steps. I "cleaned" my system to the best of my abilities (as previously described; see below) and then did

sudo apt-get install r-base

This seemed (as I previously said on the Ubuntu Mate Community list, from which you told me to switch the discussion to this location) to run without complaint, but produced no executable.

I tried

dpkg -l | grep "^ii -r"

just now, following your example, and got no output whatever. So it would seem that "dpkg" thinks that r-base has not been installed.

But the output from "sudo apt-get install r-base" seems to say that it has been installed. What is going on?

Added: I have solved the problem. Elsewhere it was suggested to me that I try doing

dpkg -l r-base-core

This produced the enlightening output:

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-  pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name             Version       Architecture  Description
+++-================-=============-=============-======================================
ii  r-base-core      3.5.2-1bionic amd64         GNU R core of statistical computation

The nature of the message prompted me to try

sudo apt purge r-base-core

which ran and said that it was removing a whole lot of stuff.

I then tried

 sudo apt-get install r-base-core

which ran and gave a whole lot more output than was previously produced when I ran "sudo apt-get install r-base". (Note: I had been typing r-base and NOT r-base-core.) It indicated that it was doing lots of stuff that looked promising in respect of actually installing R.

And in fact the promise was fulfilled. I then started R and got:

R version 3.5.2 (2018-12-20) -- "Eggshell Igloo"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

Ta-da!!!

The problem may have been that previously I had been saying

"sudo apt-get install r-base" rather than

"sudo apt-get install r-base-core".

It is possible that the latter is needed if R has previously been installed from source, but otherwise just "r-base" is sufficient. I am not sufficiently knowledgeable to say. Others may be able to provide insight.