| 42333 |
ripley |
1 |
% File src/library/base/man/libPaths.Rd
|
| 68948 |
ripley |
2 |
% Part of the R package, https://www.R-project.org
|
| 79829 |
ripley |
3 |
% Copyright 1995-2021 R Core Team
|
| 42333 |
ripley |
4 |
% Distributed under GPL 2 or later
|
|
|
5 |
|
| 30722 |
ripley |
6 |
\name{libPaths}
|
|
|
7 |
\title{Search Paths for Packages}
|
|
|
8 |
\alias{.Library}
|
| 40248 |
ripley |
9 |
\alias{.Library.site}
|
| 30722 |
ripley |
10 |
\alias{.libPaths}
|
| 41341 |
hornik |
11 |
\alias{R_LIBS}
|
|
|
12 |
\alias{R_LIBS_SITE}
|
|
|
13 |
\alias{R_LIBS_USER}
|
| 30722 |
ripley |
14 |
\description{
|
|
|
15 |
\code{.libPaths} gets/sets the library trees within which packages are
|
|
|
16 |
looked for.
|
|
|
17 |
}
|
|
|
18 |
\usage{
|
| 79677 |
maechler |
19 |
.libPaths(new, include.site = TRUE)
|
| 30722 |
ripley |
20 |
|
|
|
21 |
.Library
|
| 40248 |
ripley |
22 |
.Library.site
|
| 30722 |
ripley |
23 |
}
|
|
|
24 |
\arguments{
|
| 40248 |
ripley |
25 |
\item{new}{a character vector with the locations of \R library
|
| 40264 |
ripley |
26 |
trees. Tilde expansion (\code{\link{path.expand}}) is done, and if
|
| 90027 |
hornik |
27 |
any element contains one of \samp{*?[}, globbing is done where
|
| 40281 |
ripley |
28 |
supported by the platform: see \code{\link{Sys.glob}}.}
|
| 79677 |
maechler |
29 |
\item{include.site}{a logical value indicating whether the value of
|
|
|
30 |
\code{.Library.site} should be included in the new set of library
|
|
|
31 |
tree locations. Defaulting to \code{TRUE}, it is ignored when
|
|
|
32 |
\code{.libPaths} is called without the \code{new} argument.}
|
| 30722 |
ripley |
33 |
}
|
|
|
34 |
\details{
|
|
|
35 |
\code{.Library} is a character string giving the location of the
|
| 87649 |
smeyer |
36 |
default library, the \file{library} subdirectory of \var{\link{R_HOME}}.
|
| 30722 |
ripley |
37 |
|
| 40248 |
ripley |
38 |
\code{.Library.site} is a (possibly empty) character vector giving the
|
| 80241 |
hornik |
39 |
locations of the site libraries.
|
| 40248 |
ripley |
40 |
|
| 80214 |
kalibera |
41 |
\code{.libPaths} is used for getting or setting the library trees that \R
|
| 80490 |
ripley |
42 |
knows about and hence uses when looking for packages (the library search
|
| 80214 |
kalibera |
43 |
path). If called with argument \code{new}, by default, the library search
|
|
|
44 |
path is set to the existing directories in \code{unique(c(new,
|
|
|
45 |
.Library.site, .Library))} and this is returned. If \code{include.site}
|
|
|
46 |
is \code{FALSE} when the \code{new} argument is set, \code{.Library.site}
|
|
|
47 |
is not added to the new library search path. If called without the
|
|
|
48 |
\code{new} argument, a character vector with the currently active library
|
|
|
49 |
trees is returned.
|
| 30722 |
ripley |
50 |
|
| 80203 |
kalibera |
51 |
How paths in \code{new} with a trailing slash are treated is
|
| 63260 |
ripley |
52 |
OS-dependent. On a POSIX filesystem existing directories can usually
|
| 80214 |
kalibera |
53 |
be specified with a trailing slash. On Windows filepaths with a
|
| 80624 |
kalibera |
54 |
trailing slash (or backslash) are invalid and existing directories
|
|
|
55 |
specified with a trailing slash may not be added to the library search path.
|
| 63260 |
ripley |
56 |
|
| 80241 |
hornik |
57 |
At startup, the library search path is initialized from the
|
|
|
58 |
environment variables \env{R_LIBS}, \env{R_LIBS_USER} and
|
|
|
59 |
\env{R_LIBS_SITE}, which if set should give lists of directories where
|
|
|
60 |
\R library trees are rooted, colon-separated on Unix-alike systems and
|
| 80436 |
hornik |
61 |
semicolon-separated on Windows. For the latter two, a value of
|
| 80490 |
ripley |
62 |
\code{NULL} indicates an empty list of directories. (Note that as from
|
|
|
63 |
\R 4.2.0, both are set by \R start-up code if not already set or empty
|
| 84029 |
smeyer |
64 |
so can be interrogated from an \R session to find their defaults:
|
| 80490 |
ripley |
65 |
in earlier versions this was true only for \env{R_LIBS_USER}.)
|
| 40248 |
ripley |
66 |
|
| 80241 |
hornik |
67 |
First, \code{.Library.site} is initialized from \env{R_LIBS_SITE}. If
|
|
|
68 |
this is unset or empty, the \file{site-library} subdirectory of
|
|
|
69 |
\env{R_HOME} is used. Only directories which exist at the time of
|
| 83419 |
ripley |
70 |
initialization are retained. Then, \code{.libPaths()} is called with
|
|
|
71 |
the combination of the directories given by \env{R_LIBS} and
|
|
|
72 |
\env{R_LIBS_USER}. By default \env{R_LIBS} is unset, and if
|
|
|
73 |
\env{R_LIBS_USER} is unset or empty, it is set to directory
|
|
|
74 |
\file{R/\var{R.version$platform}-library/\var{x.y}} of the home
|
|
|
75 |
directory on Unix-alike systems (or
|
|
|
76 |
\file{Library/R/\var{m}/\var{x.y}/library} for CRAN macOS builds, with
|
|
|
77 |
\var{m} \code{\link{Sys.info}()["machine"]}) and
|
|
|
78 |
\file{R/win-library/\var{x.y}} subdirectory of \env{LOCALAPPDATA} on
|
|
|
79 |
Windows, for \R \var{x.y.z}.
|
| 40255 |
ripley |
80 |
|
| 47259 |
ripley |
81 |
Both \env{R_LIBS_USER} and \env{R_LIBS_SITE} feature possible
|
| 80490 |
ripley |
82 |
expansion of specifiers for \R-version-specific information as part of
|
| 41155 |
hornik |
83 |
the startup process. The possible conversion specifiers all start
|
|
|
84 |
with a \samp{\%} and are followed by a single letter (use \samp{\%\%}
|
|
|
85 |
to obtain \samp{\%}), with currently available conversion
|
|
|
86 |
specifications as follows:
|
|
|
87 |
\describe{
|
| 85935 |
hornik |
88 |
\item{\samp{\%V}}{\R version number including the patch level (e.g.,
|
| 41155 |
hornik |
89 |
\samp{2.5.0}).}
|
| 85935 |
hornik |
90 |
\item{\samp{\%v}}{\R version number excluding the patch level (e.g.,
|
| 41155 |
hornik |
91 |
\samp{2.5}).}
|
| 49612 |
hornik |
92 |
\item{\samp{\%p}}{the platform for which \R was built, the value of
|
| 47728 |
ripley |
93 |
\code{\link{R.version}$platform}.}
|
| 49612 |
hornik |
94 |
\item{\samp{\%o}}{the underlying operating system, the value of
|
| 47728 |
ripley |
95 |
\code{\link{R.version}$os}.}
|
| 49612 |
hornik |
96 |
\item{\samp{\%a}}{the architecture (CPU) \R was built on/for, the
|
| 47728 |
ripley |
97 |
value of \code{\link{R.version}$arch}.}
|
| 41155 |
hornik |
98 |
}
|
|
|
99 |
(See \code{\link{version}} for details on R version information.)
|
| 80426 |
hornik |
100 |
In addition, \samp{\%U} and \samp{\%S} expand to the \R defaults for,
|
|
|
101 |
respectively, \env{R_LIBS_USER} and \env{R_LIBS_SITE}.
|
| 41155 |
hornik |
102 |
|
| 40248 |
ripley |
103 |
Function \code{.libPaths} always uses the values of \code{.Library}
|
| 56382 |
murdoch |
104 |
and \code{.Library.site} in the base namespace. \code{.Library.site}
|
| 40248 |
ripley |
105 |
can be set by the site in \file{Rprofile.site}, which should be
|
|
|
106 |
followed by a call to \code{.libPaths(.libPaths())} to make use of the
|
|
|
107 |
updated value.
|
| 54860 |
ripley |
108 |
|
|
|
109 |
For consistency, the paths are always normalized by
|
| 61150 |
ripley |
110 |
\code{\link{normalizePath}(winslash = "/")}.
|
| 81360 |
kalibera |
111 |
|
| 90027 |
hornik |
112 |
\env{LOCALAPPDATA} (usually \file{C:\\Users\\username\\AppData\\Local}) on
|
| 81360 |
kalibera |
113 |
Windows is a hidden directory and may not be viewed by some software. It
|
|
|
114 |
may be opened by \code{shell.exec(Sys.getenv("LOCALAPPDATA"))}.
|
| 30722 |
ripley |
115 |
}
|
|
|
116 |
\value{
|
|
|
117 |
A character vector of file paths.
|
|
|
118 |
}
|
|
|
119 |
\references{
|
| 88581 |
hornik |
120 |
\bibshow{R:Becker+Chambers+Wilks:1988}
|
| 30722 |
ripley |
121 |
}
|
|
|
122 |
\seealso{
|
|
|
123 |
\code{\link{library}}
|
|
|
124 |
}
|
|
|
125 |
\examples{
|
|
|
126 |
.libPaths() # all library trees R knows about
|
|
|
127 |
}
|
|
|
128 |
\keyword{data}
|