Debian Codegraph @

man/paths.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/paths.R
3 \docType{data}
4 \name{paths}
5 \alias{paths}
6 \title{Path for storing global state}
7 \usage{
8 paths
9 }
10 \description{
11 By default, renv stores global state in the following OS-specific folders:
12
13 \tabular{ll}{
14 \strong{Platform} \tab \strong{Location} \cr
15 Linux \tab \verb{~/.cache/R/renv} \cr
16 macOS \tab \verb{~/Library/Caches/org.R-project.R/R/renv} \cr
17 Windows \tab \verb{\%LOCALAPPDATA\%/R/cache/R/renv} \cr
18 }
19
20 If desired, this path can be customized by setting the \code{RENV_PATHS_ROOT}
21 environment variable. This can be useful if you'd like, for example, multiple
22 users to be able to share a single global cache.
23 }
24 \section{Customising individual paths}{
25 The various state sub-directories can also be individually adjusted, if so
26 desired (e.g. you'd prefer to keep the cache of package installations on a
27 separate volume). The various environment variables that can be set are
28 enumerated below:
29
30 \tabular{ll}{
31 \strong{Environment Variable} \tab \strong{Description} \cr
32 \code{RENV_PATHS_ROOT} \tab The root path used for global state storage. \cr
33 \code{RENV_PATHS_LIBRARY} \tab The path to the project library. \cr
34 \code{RENV_PATHS_LIBRARY_ROOT} \tab The parent path for project libraries. \cr
35 \code{RENV_PATHS_LIBRARY_STAGING} \tab The parent path used for staged package installs. \cr
36 \code{RENV_PATHS_SANDBOX} \tab The path to the sandboxed \R system library. \cr
37 \code{RENV_PATHS_LOCKFILE} \tab The path to the \link{lockfile}. \cr
38 \code{RENV_PATHS_CELLAR} \tab The path to the cellar, containing local package binaries and sources. \cr
39 \code{RENV_PATHS_SOURCE} \tab The path containing downloaded package sources. \cr
40 \code{RENV_PATHS_BINARY} \tab The path containing downloaded package binaries. \cr
41 \code{RENV_PATHS_CACHE} \tab The path containing cached package installations. \cr
42 \code{RENV_PATHS_PREFIX} \tab An optional prefix to prepend to the constructed library / cache paths. \cr
43 \code{RENV_PATHS_RENV} \tab The path to the project's renv folder. For advanced users only. \cr
44 \code{RENV_PATHS_RTOOLS} \tab (Windows only) The path to \href{https://cran.r-project.org/bin/windows/Rtools/}{Rtools}. \cr
45 \code{RENV_PATHS_EXTSOFT} \tab (Windows only) The path containing external software needed for compilation of Windows source packages. \cr
46 }
47
48 (If you want these settings to persist in your project, it is recommended that
49 you add these to an appropriate \R startup file. For example, these could be
50 set in: a project-local \code{.Renviron}, the user-level \code{.Renviron}, or a
51 site-wide file at \code{file.path(R.home("etc"), "Renviron.site")}. See
52 \link{Startup} for more details).
53
54 Note that renv will append platform-specific and version-specific entries
55 to the set paths as appropriate. For example, if you have set:
56
57 \if{html}{\out{<div class="sourceCode">}}\preformatted{Sys.setenv(RENV_PATHS_CACHE = "/mnt/shared/renv/cache")
58 }\if{html}{\out{</div>}}
59
60 then the directory used for the cache will still depend on the renv cache
61 version (e.g. \code{v2}), the \R version (e.g. \code{3.5}) and the platform (e.g.
62 \code{x86_64-pc-linux-gnu}). For example:
63
64 \if{html}{\out{<div class="sourceCode">}}\preformatted{/mnt/shared/renv/cache/v2/R-3.5/x86_64-pc-linux-gnu
65 }\if{html}{\out{</div>}}
66
67 This ensures that you can set a single \code{RENV_PATHS_CACHE} environment variable
68 globally without worry that it may cause collisions or errors if multiple
69 versions of \R needed to interact with the same cache.
70
71 If reproducibility of a project is desired on a particular machine, it is
72 highly recommended that the renv cache of installed packages + binary
73 packages is backed up and persisted, so that packages can be easily restored
74 in the future -- installation of packages from source can often be arduous.
75 }
76
77 \section{Sharing state across operating systems}{
78 If you need to share the same cache with multiple different Linux operating
79 systems, you may want to set the \code{RENV_PATHS_PREFIX} environment variable
80 to help disambiguate the paths used on Linux. For example, setting
81 \code{RENV_PATHS_PREFIX = "ubuntu-bionic"} would instruct renv to construct a
82 cache path like:
83
84 \if{html}{\out{<div class="sourceCode">}}\preformatted{/mnt/shared/renv/cache/v2/ubuntu-bionic/R-3.5/x86_64-pc-linux-gnu
85 }\if{html}{\out{</div>}}
86
87 If this is required, it's strongly recommended that this environment
88 variable is set in your \R installation's \code{Renviron.site} file, typically
89 located at \code{file.path(R.home("etc"), "Renviron.site")}, so that it can be
90 active for any \R sessions launched on that machine.
91
92 Starting from \verb{renv 0.13.0}, you can also instruct renv to auto-generate
93 an OS-specific component to include as part of library and cache paths,
94 by setting the environment variable:
95
96 \if{html}{\out{<div class="sourceCode">}}\preformatted{RENV_PATHS_PREFIX_AUTO = TRUE
97 }\if{html}{\out{</div>}}
98
99 The prefix will be constructed based on fields within the system's
100 \verb{/etc/os-release} file. Note that this is the default behavior with
101 \verb{renv 1.0.6} when using R 4.4.0 or later.
102 }
103
104 \section{Package cellar}{
105 If your project depends on one or more \R packages that are not available in any
106 remote location, you can still provide a locally-available tarball for renv
107 to use during restore. By default, these packages should be made available in
108 the folder as specified by the \code{RENV_PATHS_CELLAR} environment variable. The
109 package sources should be placed in a file at one of these locations:
110 \itemize{
111 \item \verb{$\{RENV_PATHS_CELLAR\}/<package>_<version>.<ext>}
112 \item \verb{$\{RENV_PATHS_CELLAR\}/<package>/<package>_<version>.<ext>}
113 \item \verb{<project>/renv/cellar/<package>_<version>.<ext>}
114 \item \verb{<project>/renv/cellar/<package>/<package>_<version>.<ext>}
115 }
116
117 where \verb{.<ext>} is \code{.tar.gz} for source packages, or \code{.tgz} for binaries on
118 macOS and \code{.zip} for binaries on Windows. During \code{restore()}, renv will
119 search the cellar for a compatible package, and prefer installation with
120 that copy of the package if appropriate.
121 }
122
123 \section{Older versions}{
124 Older version of renv used a different default cache location.
125 Those cache locations are:
126
127 \tabular{ll}{
128 \strong{Platform} \tab \strong{Location} \cr
129 Linux \tab \verb{~/.local/share/renv} \cr
130 macOS \tab \verb{~/Library/Application Support/renv} \cr
131 Windows \tab \verb{\%LOCALAPPDATA\%/renv} \cr
132 }
133
134 If an renv root directory has already been created in one of the old
135 locations, that will still be used. This change was made to comply with the
136 CRAN policy requirements of \R packages.
137 }
138
139 \examples{
140 # get the path to the project library
141 path <- renv::paths$library()
142 }
143 \keyword{datasets}