2

I have a lot of packages installed in ~/R/x86_64-pc-linux-gnu-library/3.4/. Today, I opened R, and attempted to run some code, and I found that packages were not being recognised:

Error in library("some_package"): there is no package called ‘some_package’

I looked at the paths, and I got this:

.libPaths() 
[1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library" "/usr/lib/R/library"  

which explains why packages are not longer recognised. Now, I know how to solve this (add local path to R paths, e.g. modifying /etc/R/Renviron).

Notice that I updated R via sudo apt-get update.... However, the update was minor (from 3.4 to 3.4.1) (so this is not a duplicate of this question). Here is the command line output of the update/upgrade. It seems the issue might have been related to the update of /etc/R/Renviron, as the line Replacing config file /etc/R/Renviron with new version indicates.

My packages source is

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

My question is, why did this change happen? Does every minor change in R restores the paths to default? Is it somewhere explained in some documentation? I can't find a warning about it here or elsewhere.

luchonacho
  • 5,255
  • 3
  • 27
  • 41
  • I don't know why it happened, but if you start R with `sudo R` then you should be able to install the packages. – Suren Jul 05 '17 at 10:04
  • @DiscoSuperfly I have the packages already installed. The solution is to run `.libPaths("~/R/x86_64-pc-linux-gnu-library/3.4/")` in R. I want to know why a minor update removed my local path from R. I see why this happens in major updates (the path actually changes from say 3.3 to 3.4), but within 3.4, they are in the same folder. – luchonacho Jul 05 '17 at 10:11

1 Answers1

1

It's related to 3.4.1's new(?) default behaviour of making the same library of R packages available to all users on your Linux system. See here for a neat solution: https://stackoverflow.com/a/44903158/4115816

(The thread also describes some other options.)

Grant
  • 1,101
  • 10
  • 19