Change .libPaths for personal library permanently

When I updated my R to version 4.1, my user library wasn't updated to 4.1. This seems to be causing confusion to one of my programs. I can use .libPaths() to reset the location of my 4.1 library at the start of each session. But there must be a way to change it more permanently. Why didn't it get updated originally, and any suggestions on making this change permanent?
Thanks in advance.
Larry Hunsicker

Maybe you have set your library path in a startup file (Rprofile or Renviron), since that would be the way to overwrite the default permanently.

I found the problem, and I found the solution. Along the way I found a reference to Sys.getenv and Sys.setenv (in the base package). I ran Sys.getenv and found that the R environmental variable R_LIBS_USER had been set to the old path. So I ran:

Sys.setenv("R_LIBS_USER" = "c:/larry/r/win-library/4.1"))

pointing to the new library and this fixed the problem for all of my workspaces. Of course, change the second quoted string to your own user lib, and if your OS is Windows, as mine is, be sure that you use forward slashes to separate the folder names.
Larry Hunsicker

Just be aware that Sys.setenv is not going to be persistent, next time you restart your system is very likely going to get back to the default (or manually set in a startup file) value.

I just rebooted the system, and the change has stayed. How are the variables of the R system environment set? Could you point me to documentation of the R startup sequence? Where are the persistent defaults stored?
In any case, my solution appears to have solved my problem in a persistent fashion.
Larry Hunsicker

This article explains startup files in the context of RStudio Workbench but most of it is also valid for the open source version

I'm glad it solved your problem but it might not have worked the way you think, anyway, the result is what matters for you.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.