Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R not picking up user library

Tags:

linux

r

I have a Fedora 30 system with R 3.6.0 and the user library is set in Renviron as this one:

R_LIBS_USER=${R_LIBS_USER-'~/R/x86_64-redhat-linux-gnu-library/3.6'}

And indeed it shows up in an interactive R session:

> Sys.getenv('R_LIBS_USER')
[1] "~/R/x86_64-redhat-linux-gnu-library/3.6"

> .libPaths()
[1] "/home/mu/R/x86_64-redhat-linux-gnu-library/3.6"
[2] "/usr/lib64/R/library"                          
[3] "/usr/share/R/library"     

> .Library
[1] "/usr/lib64/R/library"

> .Library.site
[1] "/usr/lib64/R/library" "/usr/share/R/library"

But then I also have a Debian 10 system where in the /etc/Renviron I have pretty much exactly the same line:

R_LIBS_USER=${R_LIBS_USER-'~/R/x86_64-pc-linux-gnu-library/3.5'}

But it does not show up on my library search path, though the environment variable is there:

> Sys.getenv('R_LIBS_USER')
[1] "~/R/x86_64-pc-linux-gnu-library/3.5"

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

> .Library
[1] "/usr/lib/R/library"

> .Library.site
[1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library"      
[3] "/usr/lib/R/library"

When I install packages it also suggests to install into that library, but then it does not find them and crashes, see this other question. What is missing for this directory to also make it into the library path?

like image 328
Martin Ueding Avatar asked Sep 19 '25 22:09

Martin Ueding


1 Answers

If you have a ~/.Renviron, it might overwrite things. And if you have a ~/.Rprofile which does a call to .libPaths with a non-existant directory you will have neither of them in your search path.

like image 144
Martin Ueding Avatar answered Sep 22 '25 12:09

Martin Ueding