In C:/Program Files/R/R-3.6.1/library I've got default packages, and empty personal library.
Then I have source of my package with DESCRIPTION:
Package: x
Type: Package
Title: x
Version: 0.3.9006
License: MIT
Encoding: UTF-8
LazyData: true
Depends: R (>= 3.0.0)
Imports:
rlang (<= 0.3.4)
RoxygenNote: 6.1.1
and .renvignore with ignored everything except this DESCRIPTION file.
With that I run in R (3.6.1):
install.packages('renv') # it's installed to my personal library
renv::dependencies()
> Finding R package dependencies ... Done!
Source Package Require Version Dev
> 3 C:/Users/x/Desktop/x/x/x/DESCRIPTION R >= 3.0.0 FALSE
> 4 C:/Users/x/Desktop/x/x/x/DESCRIPTION rlang <= 0.3.4 FALSE
it's clear that I wants rlang 0.3.4.
Then I run:
r$> renv::init()
* Discovering package dependencies ... Done!
* Copying packages into the cache ... Done!
The following package(s) will be updated in the lockfile:
# CRAN ===============================
- rlang [* -> 0.4.2]
* Lockfile written to 'C:/Users/x/Desktop/x/x/renv.lock'.
* Project 'C:/Users/x/Desktop/x/x' loaded. [renv 0.8.3]
* renv activated -- please restart the R session.
And as you can see I get rlang 0.4.2.
How I can get version of packages, that I have in requirements?
renv::init() does not look at package versions in the DESCRIPTION file when deciding what to install. It simply forks the state of your current user library, giving you an isolated "clone" of the current state of your user library.
You can use renv::install() to instead install packages respecting requirements declared in the DESCRIPTION file, although note that you might need to request a specific version with e.g.
Kevin, thank you so much for your reply.
But I start with empty library, I have rlang installed nowhere, and then init tries to install it, so I guess it looks into DESCRIPTION (this is only place where I have rlang mentioned)
EDIT:
And by the way, I guess I cannot run renv::install() in a way that will install for me all packages in DESCRIPTION in specified versions?