1

I'm trying to use a linux server with R installed. Apparently the R system library has old versions of non-base packages installed like dplyr and testthat. Because i don't have permission to edit the system library, i'm unable to update the packages.

My plan is to only use a user library, so I can controll the package versions myself. However i'm unable to remove the "/usr/lib64/R/library" folder from .libPaths(). I tried changing the environment variables R_LIBS_SITE and R_LIBS with the .Renviron and .Rprofile files to a different folder, but the /usr/lib64/R/library folder will always be present. Removing it with the command .libPaths(.libPaths()[1:2]) doesn't work either.

Is there a way to remove the system library from .libPaths(), so I'm not depending on the update policy of the server admin?

  • This might help https://stackoverflow.com/questions/15170399/change-r-default-library-path-using-libpaths-in-rprofile-site-fails-to-work . – R.S. Mar 01 '19 at 14:41
  • Thanks for the link, it has valuable information. I can't find a way to remove the system library from .liPaths(), however – Jelger van Zaane Mar 01 '19 at 15:19

2 Answers2

2

You can't remove the system library, because that's where the base packages live. They can't be installed anywhere else, and R won't work without them.

Best would be for you to get your sysadmin to update the system library. Those obsolete packages probably contain bugs.

If you can't do that, then run update.packages(instlib = "local") to install all the latest versions in the library named "local". (Substitute your own local lib name, of course.) This requires all your users to specify .libPaths("local") when they start, and some will likely forget, so it's not as good.

It might be easiest for you to just install a full copy of R in your own account. Then you'll have control of things, and anyone using your copy will get your library.

(There's a new release (3.5.3) coming in ten days; you might wait for that, or install one of the betas or RCs, which should be available now, then update again when the final release arrives.)

user2554330
  • 37,248
  • 4
  • 43
  • 90
1

For me, it works to use

 .libPaths(.libPaths()[2:1])

This will still search the system library, but only after it searches my personal library, so if I have a newer version, it uses that. Note: I used .libPaths()[2:1] not .libPaths()[1:2]

G5W
  • 36,531
  • 10
  • 47
  • 80
  • When I try to install a package the dependecies will not be installed when it's already in the system library, the install will fail with this error: `Error: package or namespace load failed for ‘covr’: .onLoad failed in loadNamespace() for 'covr', details: call: NULL error: package ‘lazyeval’ was installed by an R version with different internals; it needs to be reinstalled for use with this R version` – Jelger van Zaane Mar 01 '19 at 15:00
  • Have you tried installing the dependencies using `install.packages(pkgs, lib=MyLib` ? – G5W Mar 01 '19 at 15:05
  • I tried installing all dependencies separately, and when I do this, it'll work. However, my aim is to make a generic and automated solution, so other users won't need to install all dependencies by hand. – Jelger van Zaane Mar 01 '19 at 15:17
  • @G5W: Your answer doesn't do what you say it does. If you just have one path in your call to `.libPaths()`, it will be searched first, then the system library. If you have two, those two will be searched in the order you specify, and then the system library will be searched: but only if it wasn't one of the two. So your recipe will not force the system library to be searched second. It is *normally* searched second, but your recipe might make it be searched first. – user2554330 Mar 01 '19 at 19:40