On 16 March 2023 at 13:39, Felipe Contreras wrote: | I see R by default installs packages in ~/R. I know I can change the | default directory with R_LIBS_USER, but software shouldn't be | polluting the home directory. | | For example both python and node install packages to ~/.local/lib, | ruby to ~/.local/share. They don't install to for example ~/node. | | R should do the same: it should install packages to somewhere inside | ~/.local by default. Use of ~/.local is a fairly recent convention (relative to the time R has been around, which is now decades) and one which R supports already eg in the (rather useful) portable config directories: > tools::R_user_dir("r2u") [1] "/home/edd/.local/share/R/r2u" > Your best bet really to govern your .libPaths from your Rprofile.site and Renviron.site rather than asking a few million R users to adjust from past practice. Also: personal preferences differ. I think of Linux as multi-tenant and expect other (even system) users to have access to packages I install. So I am happy with this default --- which goes after all back to fruitful discussion in a bar in Vienna with Kurt and Fritz some 20 years ago: > .libPaths() [1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library" [3] "/usr/lib/R/library" > Dirk -- dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
> Your best bet really to govern your .libPaths from your Rprofile.site andRenviron.site ... To do this for any version of R, one can add: R_LIBS_USER=~/.local/share/R/%p-library/%v to ~/.Renviron or the Renviron.site file. This automatically expands to the platform and R x.y version early on when R starts up, e.g. ~/.local/share/R/x86_64-pc-linux-gnu-library/4.2.> rather than asking a few million R users to adjust from past practice.We're all starting out with a fresh R_LIBS_USER once a year when a new minor version of R is released, so changing the default should be doable without major troubles. On MS Windows, this move has already been made. When R 4.2.0 was released, the default R_LIBS_USER location on MS Windows was changed, similarly, to the Local Application Data directory in R (>= 4.2.0), e.g. C:\Users\alice\AppData\Local\R\win-library\4.2. /Henrik On Thu, Mar 16, 2023 at 3:09?PM Dirk Eddelbuettel <edd at debian.org> wrote:> > > On 16 March 2023 at 13:39, Felipe Contreras wrote: > | I see R by default installs packages in ~/R. I know I can change the > | default directory with R_LIBS_USER, but software shouldn't be > | polluting the home directory. > | > | For example both python and node install packages to ~/.local/lib, > | ruby to ~/.local/share. They don't install to for example ~/node. > | > | R should do the same: it should install packages to somewhere inside > | ~/.local by default. > > Use of ~/.local is a fairly recent convention (relative to the time R has > been around, which is now decades) and one which R supports already eg in the > (rather useful) portable config directories: > > > tools::R_user_dir("r2u") > [1] "/home/edd/.local/share/R/r2u" > > > > Your best bet really to govern your .libPaths from your Rprofile.site and > Renviron.site rather than asking a few million R users to adjust from past > practice. > > Also: personal preferences differ. I think of Linux as multi-tenant and > expect other (even system) users to have access to packages I install. So I > am happy with this default --- which goes after all back to fruitful > discussion in a bar in Vienna with Kurt and Fritz some 20 years ago: > > > .libPaths() > [1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library" > [3] "/usr/lib/R/library" > > > > Dirk > > -- > dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
On Thu, Mar 16, 2023 at 4:08?PM Dirk Eddelbuettel <edd at debian.org> wrote:> > > On 16 March 2023 at 13:39, Felipe Contreras wrote: > | I see R by default installs packages in ~/R. I know I can change the > | default directory with R_LIBS_USER, but software shouldn't be > | polluting the home directory. > | > | For example both python and node install packages to ~/.local/lib, > | ruby to ~/.local/share. They don't install to for example ~/node. > | > | R should do the same: it should install packages to somewhere inside > | ~/.local by default. > > Use of ~/.local is a fairly recent convention (relative to the time R has > been around, which is now decades) and one which R supports already eg in the > (rather useful) portable config directories: > > > tools::R_user_dir("r2u") > [1] "/home/edd/.local/share/R/r2u" > > > > Your best bet really to govern your .libPaths from your Rprofile.site and > Renviron.siteI already have fixed it for myself, my request was about the default, so most users don't have to fix it for themselves too.> rather than asking a few million R users to adjust from past > practice.Why would they have to adjust anything? Just expand %U to both: paste(c( file.path(home, ".local", "lib", "r", x.y), file.path(home, "R", paste0(R.version$platform, "-library"), x.y) ), collapse = ":") Then R would install packages to the new location in new installations by default, but still use packages from the old location if present. Moreover, this location is going to change the next time the minor version is bumped anyway. Cheers. -- Felipe Contreras