25

R 3.5.0 installation packages for Ubuntu Xenial (16.04) do not yet exist on the ubuntu mirror sites. Is there an alternative method for updating R to 3.5.0 on ubuntu xenial? Alternatively, is there a different method to update R to 3.5.0?

4
  • 1
    Have you had a look at this walkthrough? The author doesn't explicitly say it anywhere, but these are directions for installing 3.5
    – Hee Jin
    May 3, 2018 at 15:52
  • Try here: askubuntu.com/questions/862403/…
    – valiano
    May 3, 2018 at 17:55
  • 1
    @Emily: The walkthrough you linked to is about installing R from source.
    – krlmlr
    Jun 2, 2018 at 9:37
  • 1
    @valiano: This answers a different question.
    – krlmlr
    Jun 2, 2018 at 9:37

4 Answers 4

26

R 3.5 are currently only available from a PPA, because some of CRAN's packages have problems building with R 3.5.

Proceed at your own risk.

The procedure that worked for me is:

  1. Remove all r-cran-* packages from your system (YMMV, I'm usually installing packages from source and have very few of these)

    • Search with dpkg -l | grep r-cran-
  2. Add Michael Rutter's PPA:

    sudo add-apt-repository ppa:marutter/rrutter3.5
    sudo apt-get update
    
  3. Upgrade R

    sudo apt install r-api-3.5
    
  4. Install all packages you need from source (to a personal or site library via install.packages()) or by installing the corresponding r-cran-* Ubuntu package.

    I use the following script to reinstall all packages my packages from my personal site library for R 3.4:

    installed <- rownames(installed.packages())
    pkgs <- dir("~/R/x86_64-pc-linux-gnu-library/3.4")
    new <- setdiff(pkgs, installed)
    new
    install.packages(new)
    

    If you have a machine with multiple CPUs, you can speed up the process, for example:

    install.packages(new, Ncpus = 6)
    

References

6
  • 3
    The method above worked entirely correctly for me. (Thanks to Krlmlr.) Two additional suggestions for those not experienced with Ubuntu: 1. Remove prior r-cran-* packages with: sudo apt-get remove r-cran-* 2. After adding Michael Rutter's PPA, remember to run: sudo apt-get update Jun 8, 2018 at 1:36
  • The method above worked entirely correctly for me. (Thanks to Krlmlr.) Two additional suggestions for those not experienced with Ubuntu: 1. Remove prior r-cran-* packages with: sudo apt-get remove r-cran-* 2. After adding Michael Rutter's PPA, remember to run: sudo apt-get update before running: sudo apt install r-api-3.5 Jun 8, 2018 at 1:42
  • @Larry: Thanks. Can you edit the post?
    – krlmlr
    Jun 8, 2018 at 11:10
  • @krlmlr I suggest that you remove Ncpus = 6 from the answer. It might lead to unexpected slow-downs, specially for people that (i) don't read the code fully before copy/paste; and (ii) will do this in a personal computer. The option is also not required for the answer. Jun 29, 2018 at 7:20
  • 1
    @fridaymeetssunday: Added comment. Agree that Ncpus = 6 may be slow on weak machines, but then nobody should copy-paste without at least scanning the code.
    – krlmlr
    Jun 29, 2018 at 8:02
14

The CRAN site has been updated since's @krlmlr's response in early June: https://cran.r-project.org/bin/linux/ubuntu/.

The CRAN instructions have several steps, but the summary is that the sources.list file should reference a repository that's specific to version 3.5.x & 3.6.x. The entry is something like

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

instead of the previous (versionless) entry of

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

The relevant description from the website (which will eventually change):

R 3.6 packages for Ubuntu on i386 and amd64 are available for most stable Desktop releases of Ubuntu until their official end of life date. However, only the latest Long Term Support (LTS) release is fully supported. As of November 18, 2018 the supported releases are Xenial Xerus (16.04; LTS), Trusty Tahr (14.04; LTS), Bionic Beaver (18.04;LTS), Cosmic Cuttlefish (18.10), and Disco Dingo (19.04). Note, to install R 3.6 packages, a different sources.list entry is needed. See below for details. Even though R has moved to version 3.6, for compatibility the sources.list entry still uses the cran3.5 designation.


edit 2019-05-13: update for last month's release of R 3.6.0.

2

The xenial-cran35/ version of the repo does NOT work if you have a "default release" set in apt, as is the case in some distros that work on top of Ubuntu, such as Mint. For my Mint distro, there exists a file /etc/apt/apt.conf.d/01ubuntu inside of which it declares the Default-Release "xenial"; What this means is that, since r-base exists in the ubuntu repo at version 3.2, with release "xenial", it'll never use the 3.6 branch from the other repo, because the release name for that repo is "xenial-cran35". You need to edit that file to change the default release to "xenail-cran35", or do something more pointed using apt preference files (https://wiki.debian.org/AptPreferences#A.2Fetc.2Fapt.2Fpreferences).

This is basically R's fault for having a poorly formatted repo. They should have had 2 repos, each of which had a "xenial" release folder, one url for their 3.2 branch work and one for the 3.5+ branch work. Instead they have one repo, and have bastardized the "release name" instead, which just sort of happens to work for base Ubuntu, but won't work if you have non-base configuration of apt in this way.

0
0

This needs to be done like so currently:

sudo apt purge r-base* r-recommended r-cran-*
sudo apt autoremove
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 E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo apt update
sudo apt install r-base-dev

'bionic' can be changed to your version of ubuntu; check the R docs: https://cran.r-project.org/bin/linux/ubuntu/

https://stackoverflow.com/a/56378217/4549682

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.