Skip to content

Commit

Permalink
Change the default location of the personal library on Windows to be in
Browse files Browse the repository at this point in the history
LOCALAPPDATA, instead of CSIDL_PERSONAL (PR#17842).


git-svn-id: https://svn.r-project.org/R/branches/R-ucrt@81354 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
kalibera committed Dec 12, 2021
1 parent d7cc342 commit 9196047
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
12 changes: 10 additions & 2 deletions doc/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,15 @@
installation time. See
\url{https://developer.r-project.org/Blog/public/2021/12/07/upcoming-changes-in-r-4.2-on-windows}.
This measure is intended to end before R 4.2 is released.


\item The personal library on Windows, folder
\file{R\\win-library\\x.y} where \file{x.y} stands for \R release
\file{x.y.z}, is now by default a subdirectory of Local Application
Data (usually a hidden directory
\file{C:\\Users\\username\\AppData\\Local}). Use
\code{shell.exec(.libPaths()[1])} to open the personal library in
explorer when it is first in the list (\PR{17842}).

\item \R uses a new 64-bit Tcl/Tk bundle. The previous 32-bit/64-bit
combined bundle had a different layout and can no longer be used.

Expand Down Expand Up @@ -228,7 +236,7 @@
is required from the user.

\item The default installation directory of R for user-only installation
has been changed to the User Program Files (usually
has been changed to the User Program Files (usually a hidden directory
\file{C:\\Users\\username\\AppData\\Local\\Programs}) to follow Windows
conventions. Use \code{shell.exec(R.home())} to open \R installation
directory in explorer (\PR{17842}).
Expand Down
10 changes: 7 additions & 3 deletions doc/manual/rw-FAQ.texi
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ are quite deliberately installed in parallel folders so you can keep old
versions around if you wish.

For those with a personal library (folder @file{R\win-library\@var{x.y}}
of your home directory, you will need to update that too when the minor version of R
of your @file{$@{LOCALAPPDATA@}} directory in R since 4.2.0 or of your home
directory with earlier versions of R),
you will need to update that too when the minor version of R
changes (e.g.@: from 4.0.2 to 4.1.0). A simple way to do so is to
copy (say) @file{R\win-library\4.0} to @file{R\win-library\4.1} before
running @code{update.packages(checkBuilt=TRUE, ask=FALSE)}.
Expand Down Expand Up @@ -1110,8 +1112,10 @@ library(mypkg, lib.loc="p:/myRlib")
@end example

You can also have a personal library, which defaults to the directory
@file{R\win-library\@var{x.y}} of your home directory for versions
@var{x.y.z} of R. This location can be changed by setting the
@file{R\win-library\@var{x.y}} of your @file{$@{LOCALAPPDATA@}} directory
(e.g. @file{C:\Users\username\AppData\Local}) for versions
@var{x.y.z} since R 4.2.0. With older versions of R, it was a subdirectory
of your home directory by default. This location can be changed by setting the
environment variable @env{R_LIBS_USER}, and can be found from inside R
by running @code{Sys.getenv("R_LIBS_USER")}. This will only be used if
it exists so you may need to create it: you can use
Expand Down
4 changes: 2 additions & 2 deletions src/library/base/R/library.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# File src/library/base/R/library.R
# Part of the R package, https://www.R-project.org
#
# Copyright (C) 1995-2020 The R Core Team
# Copyright (C) 1995-2021 The R Core Team
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -996,7 +996,7 @@ function(x)
x.y <- paste0(R.version$major, ".",
sub("[.].*", "", R.version$minor))
if(.Platform$OS.type == "windows")
file.path(home, "R", "win-library", x.y)
file.path(Sys.getenv("LOCALAPPDATA"), "R", "win-library", x.y)
else if(s["sysname"] == "Darwin")
file.path(home, "Library", "R", s["machine"], x.y, "library")
else
Expand Down
8 changes: 7 additions & 1 deletion src/library/base/man/libPaths.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@
on Unix-alike systems
(or \file{Library/R/\var{m}/\var{x.y}/library} for CRAN macOS
builds, with \var{m} \code{\link{Sys.info}()["machine"]})
and \file{R/win-library/\var{x.y}} on Windows, for \R \var{x.y.z}.
and \file{R/win-library/\var{x.y}} subdirectory of \env{LOCALAPPDATA} on Windows
(before \R 4.2.0, it was a subdirectory of the home directory even on
Windows), for \R \var{x.y.z}.

Both \env{R_LIBS_USER} and \env{R_LIBS_SITE} feature possible
expansion of specifiers for \R-version-specific information as part of
Expand Down Expand Up @@ -109,6 +111,10 @@

For consistency, the paths are always normalized by
\code{\link{normalizePath}(winslash = "/")}.

\env{LOCALAPPDATA} (usually \code{C:\\Users\\username\\AppData\\Local}) on
Windows is a hidden directory and may not be viewed by some software. It
may be opened by \code{shell.exec(Sys.getenv("LOCALAPPDATA"))}.
}
\value{
A character vector of file paths.
Expand Down

0 comments on commit 9196047

Please sign in to comment.