Skip to content

adjusting .libPaths

6 messages · Kevin Ushey, Ken Knoblauch, Duncan Murdoch

#
Hi,

In R 4.2, when I look at .libPaths() from within the standard R gui, I 
see:

.libPaths()
[1] "/Users/ken/Library/R/x86_64/4.2/library"
[2] "/Users/ken/Library/R/4.1/library"
[3] "/Library/Frameworks/R.framework/Versions/4.2/Resources/library"

 From a terminal, I get
[1] "/Users/ken/Library/R/4.1/library"
[2] "/Library/Frameworks/R.framework/Versions/4.2/Resources/library"

The old 4.1 directory, I suspect, should not be there.  From 
Sys.getenv(), I see

R_LIBS                       /Users/ken/Library/R/x86_64/4.2/library
R_LIBS_SITE                  
/Library/Frameworks/R.framework/Resources/site-library
R_LIBS_USER                  /Users/ken/Library/R/4.1/library

and the system Renviron file contains

uc7131:Resources ken$ grep R_LIBS etc/Renviron
R_LIBS_USER=${R_LIBS_USER:-'%U'}
R_LIBS_SITE=${R_LIBS_SITE:-'%S'}

but I wouldn't know what to adjust these to, to fix this (if I even 
should).

In Rstudio (which is not the problem of this list), I also get
[1] "/Users/ken/Library/R/4.1/library"
[2] "/Library/Frameworks/R.framework/Versions/4.2/Resources/library"

and I would guess the 4.1 entry is why Rstudio bombs when I try to 
execute any graphics.

I would be grateful for any suggestions as to how to fix this.

Thank you.

best,

Ken
#
On 28/04/2022 9:44 a.m., Kenneth Knoblauch wrote:
I'd guess the 41 isn't coming from the system file, but from a user file 
on your account or in the directory where you start Rgui.  Running 
getwd() as the first command might find that dir, as long as some 
profile code hasn't changed it.

The filename might be ".Renviron" rather than "Renviron"

Duncan Murdoch
#
That's it! There was a .Renviron file in my home directory with the one
line

R_LIBS_USER="/Users/ken/Library/R/4.1/library"

so I changed it to

R_LIBS_USER="/Users/ken/Library/R/x86_64/4.2/library"

and now I get in the Rgui, R terminal and Rstudio

libPaths()
[1] "/Users/ken/Library/R/x86_64/4.2/library"
[2] "/Library/Frameworks/R.framework/Versions/4.2/Resources/library"

which is what I expected to have in the first place.

Thank you, Duncan.

best,
#
FWIW, you shouldn't need to set R_LIBS_USER in this way -- R will
choose a sensible default value for you based on your platform + the
version of R being launched.

I suspect you would see the "right" behavior if you removed that entry
from your .Renviron altogether (and you wouldn't need to remember to
change it in the future)

See also ?.expand_R_libs_env_var for more information.

Best,
Kevin

On Thu, Apr 28, 2022 at 7:40 AM Kenneth Knoblauch
<ken.knoblauch at inserm.fr> wrote:
#
Thanks Kevin,

I was thinking after I replied to Duncan that I could just delete the . Renviron file because it doesn?t have anything else in it. 

Ken

Sent from my iPhone
#
On 28/04/2022 1:55 p.m., Kevin Ushey wrote:
Thanks for pointing that out.  In the past, I thought the following 
could happen:

  - a user with no home dir library tries to install a package.

  - R can't write to the system library, so creates a home dir library 
and writes there.  The package is successfully installed.

  - Next session, R is started without specifying a home dir library, 
and can't find the new package.

The help page you point to makes it look as though this won't happen. 
Maybe it never did:  maybe the problems only arose when people specified 
R_LIBS_USER incorrectly.

Duncan Murdoch