Debian Codegraph @

man/init.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/init.R
3 \name{init}
4 \alias{init}
5 \title{Use renv in a project}
6 \usage{
7 init(
8 project = NULL,
9 ...,
10 profile = NULL,
11 settings = NULL,
12 bare = FALSE,
13 force = FALSE,
14 repos = NULL,
15 bioconductor = NULL,
16 load = TRUE,
17 restart = interactive()
18 )
19 }
20 \arguments{
21 \item{project}{The project directory. When \code{NULL} (the default), the current
22 working directory will be used. The \R working directory will be
23 changed to match the requested project directory.}
24
25 \item{...}{Unused arguments, reserved for future expansion. If any arguments
26 are matched to \code{...}, renv will signal an error.}
27
28 \item{profile}{The profile to be activated. See
29 \code{vignette("profiles", package = "renv")} for more information.
30 When \code{NULL} (the default), the profile is not changed. Use
31 \code{profile = "default"} to revert to the default \code{renv} profile.}
32
33 \item{settings}{A list of \link{settings} to be used with the newly-initialized
34 project.}
35
36 \item{bare}{Boolean; initialize the project with an empty project library,
37 without attempting to discover and install \R package dependencies?}
38
39 \item{force}{Boolean; force initialization? By default, renv will refuse
40 to initialize the home directory as a project, to defend against accidental
41 misusages of \code{init()}.}
42
43 \item{repos}{The \R repositories to be used in this project.
44 See \strong{Repositories} for more details.}
45
46 \item{bioconductor}{The version of Bioconductor to be used with this project.
47 Setting this may be appropriate if renv is unable to determine that your
48 project depends on a package normally available from Bioconductor. Set this
49 to \code{TRUE} to use the default version of Bioconductor recommended by the
50 \code{BiocManager} package. When \code{NULL} (the default), the value is inferred
51 from the \code{bioconductor.init} configuration option -- see \link{config} for more
52 details.}
53
54 \item{load}{Boolean; should the project be loaded after it is initialized?}
55
56 \item{restart}{Boolean; attempt to restart the \R session after initializing
57 the project? A session restart will be attempted if the \code{"restart"} \R
58 option is set by the frontend hosting \R.}
59 }
60 \value{
61 The project directory, invisibly. Note that this function is normally
62 called for its side effects.
63 }
64 \description{
65 Call \code{renv::init()} to start using renv in the current project. This will:
66 \enumerate{
67 \item Set up project infrastructure (as described in \code{\link[=scaffold]{scaffold()}}) including
68 the project library and the \code{.Rprofile} that ensures renv will be
69 used in all future sessions,
70 \item Discover the packages that are currently being used in your project
71 (via \code{\link[=dependencies]{dependencies()}}), and install them into the project library
72 (as described in \code{\link[=hydrate]{hydrate()}}),
73 \item Create a lockfile that records the state of the project library so it
74 can be restored by others (as described in \code{\link[=snapshot]{snapshot()}}),
75 \item Restart R (if running inside RStudio).
76 }
77
78 If you call \code{renv::init()} with a project that is already using renv, it will
79 attempt to do the right thing: it will restore the project library if it's
80 missing, or otherwise ask you what to do.
81 }
82 \section{Repositories}{
83 If the default \R repositories have not already been set, renv will use
84 the \href{https://packagemanager.posit.co/}{Posit Public Package Manager} CRAN
85 mirror for package installation. The primary benefit to using this mirror is
86 that it can provide pre-built binaries for \R packages on a variety of
87 commonly-used Linux distributions. This behavior can be configured or
88 disabled if desired -- see the options in \code{\link[=config]{config()}} for more details.
89 }
90
91 \examples{
92
93 \dontrun{
94
95 # disable automatic snapshots
96 auto.snapshot <- getOption("renv.config.auto.snapshot")
97 options(renv.config.auto.snapshot = FALSE)
98
99 # initialize a new project (with an empty R library)
100 renv::init(bare = TRUE)
101
102 # install digest 0.6.19
103 renv::install("[email protected]")
104
105 # save library state to lockfile
106 renv::snapshot()
107
108 # remove digest from library
109 renv::remove("digest")
110
111 # check library status
112 renv::status()
113
114 # restore lockfile, thereby reinstalling digest 0.6.19
115 renv::restore()
116
117 # restore automatic snapshots
118 options(renv.config.auto.snapshot = auto.snapshot)
119
120 }
121 }