Code Monkey home page Code Monkey logo

renv's Introduction

renv

Lifecycle: stable CRAN status R-CMD-check

Overview

The renv package1 helps you create reproducible environments for your R projects. Use renv to make your R projects more isolated, portable and reproducible.

  • Isolated: Installing a new or updated package for one project won’t break your other projects, and vice versa. That’s because renv gives each project its own private library.
  • Portable: Easily transport your projects from one computer to another, even across different platforms. renv makes it easy to install the packages your project depends on.
  • Reproducible: renv records the exact package versions you depend on, and ensures those exact versions are the ones that get installed wherever you go.

Installation

Install the latest version of renv from CRAN with:

install.packages("renv")

Workflow

A diagram showing the most important verbs and nouns of renv. Projects start with init(), which creates a project library using packages from the system library. snapshot() updates the lockfile using the packages installed in the project library, where restore() installs packages into the project library using the metadata from the lockfile, and status() compares the lockfile to the project library. You install and update packages from CRAN and GitHub using install() and update(), but because you'll need to do this for multiple projects, renv uses cache to make this fast.

Use renv::init() to initialize renv in a new or existing project. This will set up a project library, containing all the packages you’re currently using. The packages (and all the metadata needed to reinstall them) are recorded into a lockfile, renv.lock, and a .Rprofile ensures that the library is used every time you open that project.

As you continue to work on your project, you will install and upgrade packages, either using install.packages() and update.packages() or renv::install() and renv::update(). After you’ve confirmed your code works as expected, use renv::snapshot() to record the packages and their sources in the lockfile.

Later, if you need to share your code with someone else or run your code on new machine, your collaborator (or you) can call renv::restore() to reinstall the specific package versions recorded in the lockfile.

Learning more

If this is your first time using renv, we strongly recommend starting with the Introduction to renv vignette: this will help you understand the most important verbs and nouns of renv.

If you have a question about renv, please first check the FAQ to see whether your question has already been addressed. If it hasn’t, please feel free to ask on the Posit Forum.

If you believe you’ve found a bug in renv, please file a bug (and, if possible, a reproducible example) at https://github.com/rstudio/renv/issues.

Footnotes

  1. Pronounced “R” “env”

renv's People

Contributors

aronatkins avatar blairj09 avatar cderv avatar cstepper avatar edavidaja avatar fh-mthomson avatar gadenbuie avatar hadley avatar jennybc avatar jjallaire avatar jrdnbradford avatar kevinushey avatar khughitt avatar kiwiroy avatar klmr avatar krlmlr avatar mcanouil avatar miguelrodo avatar mthomas-ketchbrook avatar niknakk avatar njtierney avatar r-suzuki avatar randy3k avatar ratnanil avatar robbfitzsimmons avatar salim-b avatar swt30 avatar toph-allen avatar vandenman avatar zkamvar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

renv's Issues

Setting RENV_PATHS_CACHE does not works

Setting RENV_PATHS_ROOT seems to work

Sys.setenv(RENV_PATHS_ROOT="~/.renv")
renv:::renv_paths_cache()
#> [1] "~/.renv/R-3.5/cache/v2"

but only trying to change the cache does not

Sys.setenv(RENV_PATHS_CACHE="~/.renv/mycache")
renv:::renv_paths_cache()
#> [1] "C:\\Users\\chris\\AppData\\Local/renv/R-3.5/cache/v2"

I think there is something wrong here read here

renv/R/paths.R

Line 67 in 494ce53

envvar <- sprintf("RENV_PATHS_%s", toupper(name))

is in fact

renv/R/paths.R

Line 104 in 494ce53

cacheroot <- file.path("cache", renv_cache_version())

and cacheroot has the value cache/v2 so the Env variable expected is RENV_PATHS_CACHE/V2

Sys.setenv(`RENV_PATHS_CACHE/V2`="~/.renv/mycache")
renv:::renv_paths_cache()
#> [1] "~/.renv/mycache"

I am not sure this is expected. Am I right ?

If you want I can PR something and do other check like these.

think about how to handle unknown sources

E.g.

> renv::install("reticulate")
Error: can't retrieve package 'reticulate': 'unknown' is an unrecognized source 

This occurs because I had installed reticulate from source earlier. Note that renv warns about this case when snapshot() is called:

> renv::snapshot()
The following package(s) were installed from an unknown source:

	reticulate

Consider re-installing these packages from a known source (e.g. CRAN).
Do you want to proceed? [Y/n]: 

But it would be nice to encode some explicit way of handling unknown sources, e.g.

  • Hard error (as we currently do)
  • Attempt to just install the latest version from CRAN
  • Something else?

Warnings about multiple versions are not actionable

1: Multiple hashed copies of httr [1.4.0] detected.
The version with hash '3fcffbd765a89d1eb9bedf19bc0eaa01' will be used.
2: Multiple hashed copies of mime [0.6] detected.
The version with hash '93beba1d766060a3f12a27f54ae67664' will be used.
3: Multiple hashed copies of openssl [1.2.2] detected.
The version with hash '2d036d89f158a04cc026b7520e5bd868' will be used.
4: Multiple hashed copies of askpass [1.1] detected.
The version with hash '51493f8310516c4c29a440df5badbe20' will be used.
5: Multiple hashed copies of memoise [1.1.0] detected.
The version with hash '665a0e91043f65582db2bdf8a02f65ba' will be used.
6: Multiple hashed copies of pkgload [1.0.2] detected.

What am I supposed to do when I see these warnings?

project package are not linked at first install in the cache

For a new project, if a package is not already cached, it will be installed in the cache but not linked to the project library. It will be copied from temp library where it was installed.

This is because, when a package is not in cache renv_install_package_local is used. I understand that

  • Package is downloaded in cache (binary folder on windows)
  • Package is installed in a temporary library (templib <- tempfile("renv-templib-"))
  • Cache is synchronize with renv_cache_synchronize: Temp installation is copy into cache.
    Not move and linked because library == renv_paths_library() is FALSE (one is temp lib the other is project lib)
  • Then the package is moved from temp lib to project lib

    renv/R/install.R

    Lines 69 to 73 in 4c29ee4

    # migrate packages into true library
    sources <- list.files(templib, full.names = TRUE)
    targets <- file.path(library, basename(sources))
    names(targets) <- sources
    enumerate(targets, renv_file_move, overwrite = TRUE)

At the end here, the package is not a linked folder to cache library but installed in the project.
I would have expected the package to be linked from the cache to the project library.

Seems like what this does

renv/R/cache.R

Lines 136 to 138 in 4c29ee4

if (library == renv_paths_library()) {
renv_file_move(path, cache)
renv_file_link(cache, path)

but it is not activated in this case.

Enhancement: Safe restore

Perhaps this could be outsourced to remotes or the pak package, but I think it'd be really nice if the restore was atomic; either the environment/snapshot gets restored completely or nothing changes.

One of packrat's most frustrating attributes was semi-restored environments

Higher-level Access to Python Setting

Surface an option in init to turn on Python tracking, and add a function that turns on Python support in an existing environment.

Today this is done through renv::settings$python() which is an awkward interface that can be tricky to discover

Allow shared build cache package installation to avoid duplication

In multi-tenant servers (i.e. RStudio pro products), it might be beneficial to have "build awareness" in relation to #3 (when using a shared cache).

I.e. 5 users request to build the same package version at the same time. It would be nice to see if it's possible for renv to have hooks or some type of awareness into that build pipeline so that redundancy can be reduced.

Honestly, part of this may be just awareness / extensibility and potential dependence on an arbitrary package installation client (which might provide this build awareness). I just wanted to document the idea in case it affects the development process at all.

For instance - on Connect (packrat), if 5 users attempt to install the same package at the same time, they will all build from source concurrently. Each one, as it completes, will update the cache with its completed version. This (1) is redundant and (2) burns up the CPU. Binary packages could resolve much of the issue, but in any case where binaries are not available, some additional client awareness would be useful.

Install of package from unknown source fails with renv 0.2.0-49 and later

When restoring package from unknown source with renv.verbose=TRUE there is error with following message:
Message:
Error in renv_verbose() && renv_pretty_print_records(unknown, "The following package(s) were installed from an unknown source:", : invalid 'y' type in 'x && y'.

Bug was probably introduced with commit:
327eabf

In function renv_restore_preflight_unknown_source:
renv_verbose() && renv_pretty_print(...)
probably should be:
if (renv_verbose()) { renv_pretty_print(...) }

There might be similar issue in function renv_restore_preflight_permissions.

think about Python + reticulate integration

What information about the selected version of Python do we need to capture? Some options:

  • The path to the Python executable,
  • The version of the Python interpreter used,
  • The name, or path, to a virtual environment / Conda environment.

Where do we want to capture this? Within the project options? Or as part of the lockfile? Or both?

The primary benefit of capturing these things in the lockfile is that an renv::restore() using just a project lockfile could then attempt to find the path to an appropriate Python executable, and then use that (+ a requirements.txt) to restore the Python packages in e.g. a virtual environment.

However, capturing paths may not be useful since there's no guarantee that /usr/local/bin/python on one system and /usr/local/bin/python on another system are the same.

We could enforce (or at least encourage) the use of virtual environments by name, since it would be easier to orchestrate -- e.g. "virtual environment 'tensorflow-1.13' uses Python x.y.z and these tensorflow packages", and that concept would be uniform across different machines.

The 'reproducible' solution would involve enforcing the use of virtual environments, and capturing Python by version. Then we could (in theory) attempt to find or download that particular version of Python, create a virtual environment using that Python, and then restore any packages recorded in requirements.txt.

Ultimately, I think we want to make sure it's easy for users to collaborate on the same repository, which does imply being able to easily reproduce the environment on different machines.

We should also have some provisioning for automatically selecting a project-local virtual environment called r-reticulate.

Some API proposals:

# init could take a 'python' parameter
renv::init(python = "/usr/bin/python")

# renv could activate a version of Python post-hoc
renv::settings$python("/usr/bin/python")

Philosophically should renv itself use renv?

I would argue no, because it's actually more important for a CRAN package to be compatible with current versions of packages. (Although in the short-term, I can certainly see the advantages of dog-fooding)

Rename "introduction.Rmd" to "renv.Rmd"

vignette("renv") will also work (whereas other packages might have vignettes called introduction). pkgdown also handles specially (putting in the top-level nav, rather than under articles)

Should upgrade offer to snashot version change in lockfile ?

I just upgraded my version of renv to test last commits

> renv::upgrade()
A new version of the renv package will be installed:

	[0.2.0-59] -> [0.2.0-68]

This project will use the newly-installed version of renv.

Do you want to proceed? [y/N]: Y
Retrieving 'https://api.github.com/repos/rstudio/renv/tarball/18b32a57463100e49c16246a5ee5aece32dc9029' ...
	OK [downloaded 121.9 Kb in 1.5 secs]
Installing renv [0.2.0-68] from GitHub ...
	OK (built from source)

Restarting R session...

Using libraries at paths:
- C:/Users/chris/Documents/R/win-library/3.5
- C:/Program Files/R/R-3.5.3/library
* Project '~/DEV_R/#Blogging/cderv' loaded. [renv 0.2.0-68]

I believe this should upgrade my renv version for the project. It seems the 📦 is not a the project library but in the cache

> find.package("renv")
[1] "C:/Users/chris/AppData/Local/renv/R-3.5/bootstrap/x86_64-w64-mingw32/3.5/renv/0.2.0-68/renv"

I understand it modifies the infrastucture of renv inside the project

renv/R/infrastructure.R

Lines 3 to 10 in 18b32a5

renv_write_infrastructure <- function(project = NULL, version = NULL) {
project <- project %||% renv_project()
renv_write_rprofile(project)
renv_write_rbuildignore(project)
renv_write_gitignore(project)
renv_write_activate(project, version = version)
}

However, the lock file is not updated unless I run

> renv::snapshot()
The following lockfile fields will be updated:

  [renv]
  Version: [0.2.0-59] => [0.2.0-68]
  
The lockfile will be written to '~/DEV_R/#Blogging/cderv/renv.lock'.
Do you want to proceed? [y/N]: y
* Lockfile written to '~/DEV_R/#Blogging/cderv/renv.lock'.

I would expect upgrade to update the lock file or at least ask user to do so. What do you think ?

It does not seem my project can work with another version of renv even if the lockfile says so...

I modify the version to previous one (with renv::modify())

> readLines("renv.lock", n = 2)
[1] "[renv]"           "Version=0.2.0-59"

and restarted the session.

The renv version loaded is [renv 0.2.0-68], not like the renv.lock, but determine according to activate. However, this says that everything is ok

> renv::status()
* The project is already synchronized with the lockfile.
> renv::restore()
* The project is already synchronized with the lockfile.

What do you think ?

Add `renv::list` and `renv::delete`

I think some more helpers to manage renvs that are created elsewhere in the file system (or in the home directory) would be helpful. I have long been annoyed / desiring similar helpers in virtualenv, but maybe I just do not know the incantation. rm -r has been my go-to.

should renv live in its own secret library?

Currently, renv installations live in their own private library, and renv gets loaded with some magic initialization code that gets written to renv/activate.R. We should consider the pros and cons of this approach, versus just having renv live in the private library.

Question: What do I need to share?

If I want to commit a record of my environment in GH, what do I need to commit? The most recent manifest? The whole manifest directory? Everything?

Related question:

What is the relationship between the env file and the manifest file? Do we need both?

RStudio package pane list shows all system packages

I'm so happy to see renv out in the open now! I'm just getting started and I noticed that after I run renv::init() within a newly created RStudio project that the packages pane still lists all of the available R packages in the global R library. I'm hoping that in a future update that the IDE will only show the packages in the renv custom library, like how packrat currently operates in the IDE?

Enhancement: Pre-warm cache with system libraries

For a brand new user of renv, it would be really nice if we renv would pre-populate the cache with the system library. That way, creating your first new project environment would be really fast, since the cache would already be warm with the packages you use most!

upgrade does not work with a version number

The doc says

his implies that you can call (for example) renv::upgrade(remote = "0.1.0-75) to request the installation of that particular version of renv if so required.

But

> renv::upgrade(remote = "0.2.0-59")
Error in unclass(numeric_version(rhs))[[1]] : subscript out of bounds
Call `rlang::last_error()` to see a backtrace

This is because there is no version in records

renv/R/upgrade.R

Lines 30 to 35 in 494ce53

record <- renv_remotes_parse(remote)
records <- list(renv = record)
# produce nice messages based on package versions
current <- renv_activate_version(project)
request <- record$Version

renv:::renv_remotes_parse("0.2.0-59")
#> $Package
#> [1] "0.2.0-59"
#> 
#> $Version
#> NULL
#> 
#> $Source
#> [1] "CRAN"

so request is NULL and version_compare(current, request) == 0 throws the error

It is like Package and Version field are not correct. I would expect

#> $Package
#> [1] "renv"
#> 
#> $Version
#> [1] "0.2.0-59"
#> 
#> $Source
#> [1] "Github"

Currently from the code, I don't think it is possible to install a specific renv version like documented. I understand that the call should be something like that rstudio/[email protected] to be understand as a github remote

 renv:::renv_remotes_parse("rstudio/[email protected]")

But even like that it is not ok because 0.2.0-59 is a tag name and renv_remotes_parse_github only knows how to handle branch reference (git/refs/heads/)

Github API makes a difference here between commit / branch and tag. You would need to test both or use another approach like download the tarball and read DESCRIPTION inside
https://api.github.com/repos/rstudio/renv/tarball/<any git ref>

Currently, renv::upgrade only works to upgrade from master or branch but not from a version number.

Bug? System library path is overlaid even when overlay is false

─ Session info --------
 version  R version 3.3.3 (2017-03-06)
 os       macOS  10.14.2           

I am using the latest renv build from master, 49588f3

When I activate a project virtual environment, I get the following libraries:

.libPaths()
[1] "/Users/sean/Documents/Sandbox/renv-test/renv/library/x86_64-apple-darwin13.4.0/3.3/renv-test"
[2] "/Library/Frameworks/R.framework/Versions/3.3/Resources/library"   

Here is the environment file:

[Environment]
Environment=renv-test

[R]
Version=3.3.3
Library=renv-test
Overlay=FALSE

[R/Repositories]
CRAN=https://demo.rstudiopm.com/cran/latest/
dev=https://demo.rstudiopm.com/dev/latest

I would expect only the single library path in this case, not both.

Enhancement: Check installed and pack.lock package version at session start

I was playing with renv a bit and I find it pleasant to use - specially I like that renv::install() automatically updates renv.lock, since one can easily forget to call snapshot.

One cool feature that could be added would be a check of installed package versions and versions in renv.lock when R session is started. So if versions for some package are different, then user would be asked to run renv::restore() (or there could be [y/N] prompt to call restore).

Use case:
For example there are multiple people working on the same project and then someone updates/downgrades some library and pushes changes to git. Then other guys might pull changes but they would not notice package changes and project would break for them. With this check everyone would know right away that some package version was changed and that they should update their local packages.

Enhancement: snapshot differ

The snapshots are human readable, but it'd be nice to have a "preview" method that shows what would change if you were to restore a snapshot compared to the active snapshot.

modify throws an error

currently I get an error after closing usethis::file.edit() window

> utils::file.edit("renv.lock")
Error in editor(file = file, title = title) : 
  Error in parse(targetFile) : renv.lock:1:1: unexpected '['
1: [
    ^
You can attempt to correct the error using renv.lock = edit()
Call `rlang::last_error()` to see a backtrace

Got the same with file.edit

> utils::file.edit("renv.lock")
Error in editor(file = file, title = title) : 
  Error in parse(targetFile) : renv.lock:1:1: unexpected '['
1: [
    ^
You can attempt to correct the error using renv.lock = edit()
Call `rlang::last_error()` to see a backtrace

don't know if it will stay or not (seems like it would have been removed after #15)...

Problem with Y/n prompt

Do you want to proceed? [Y/n]: 
Operation aborted.

i.e. the default actually appears to be N

Cache is not by default in ~/.renv/cache

The doc says that

renv/vignettes/renv.Rmd

Lines 145 to 147 in 494ce53

By default, the cache is installed at a path `~/.renv/cache`. If you'd like
to share the package cache across multiple users, you can do so by setting
the `RENV_PATHS_CACHE` environment variable as required. This variable can

But it is not the case... It took me some digging to find it.
by default we have

renv:::renv_paths_cache()
#> [1] "C:\\Users\\chris\\AppData\\Local/renv/R-3.5/cache/v2"

which is expected according to the code in path.R

I think the doc should be updated

allow package records with explicit source path

It would be great if the renv.lock file can also accommodate a library that is installed either from a local .tar.gz file or via devtools::install_github(, auth_token = ...). I am not sure if this is easy to facilitate though.

Great work on this library, incredibly useful!

Possible to "create" renvs at a path other than home directory?

I feel like I am seeing some type of weirdness with renvs that are tried with a path.

library(reprex)
renv::init()
#> * Virtual environment 'reprex548277d89f6' activated -- please restart the R session.
renv::activate()
#> * Virtual environment 'reprex548277d89f6' activated -- please restart the R session.
text <- "blahblah2"
renv::create(paste0("/", text))
system("ls ~/.renv/environment", intern = TRUE)
#> [1] "blah" "tmp"

system("ls ./", intern = TRUE)
#> [1] "renv"                   "reprex_reprex.R"       
#> [3] "reprex_reprex.spin.R"   "reprex_reprex.spin.Rmd"

renv::deactivate()
#> * Virtual environment deactivated -- please restart the R session.
renv::create(paste0("/tmp/", text))
system("ls ~/.renv/environment", intern = TRUE)
#> [1] "blah" "tmp"
system("ls ~/.renv/environment/tmp/", intern = TRUE)
#> [1] "blah"
renv::create(paste0("./", text))
#> Error: Local virtual environment './blahblah2' already exists.
system("ls ~/.renv/environment", intern = TRUE)
#> [1] "blah" "tmp"

system("ls ./", intern = TRUE)
#> [1] "renv"                   "reprex_reprex.R"       
#> [3] "reprex_reprex.spin.R"   "reprex_reprex.spin.Rmd"

Created on 2019-01-03 by the reprex package (v0.2.1)

I think this relates to my preferences in virtualenv 😄

Not sure if renv::init() is the only way you can get a renv within a project, and whether any project would ever be justified in having more than one renv locally.

The other use case to wonder about here is whether you could put renvs or the cache at a shared location. This is something that I know some users were interested in for packrat.

report package install failures

Right now, we suppress output from install.packages(); we should instead redirect output to a file and show that output on failure.

API for copying packages from cache into project

The motivation for this: for a project that is "finished", one might want to collect the R packages the project depends on and ensure they're installed directly in the project library (rather than linked from the cache). This is primarily just to make sure the project library could outlive the cache, or (perhaps) be more easily transplanted to another system.

This is in the same vein as packrat::bundle().

Infinite recursion if .Rprofile is in $HOME

This might not be common use case to have project root in $HOME. But when running project in docker one might have it there.

The issue seems to be, that source('activate.R') is called recursively when one have project root in $HOME or in other words when .Rprofile is in $HOME (~/.Rprofile).

The issue seems to be in 'activate.R' in lines:

# source the user profile if any, respecting R_PROFILE_USER
profile <- Sys.getenv("R_PROFILE_USER", unset = "~/.Rprofile")
if (file.exists(profile)) source(profile)

helper function to modify the repo used by the project environment

It'd be nice to have a function that sets the repo option for the environment

The alternative is teaching users to set the repo option in their .Rprofile (which is a PITA)

The current default, to record whatever repo is in use at the time of snapshot makes sense, but it'd be nice if there was an explicit way to update the repo setting through renv and have it apply to the session

Cache is not pointing to existing one

Don't know if it is a side effect of #46 but currently the cache is not the same

packageVersion("renv")
#> [1] '0.2.0.68'
renv:::renv_paths_cache()
#> [1] "C:\\Users\\chris\\AppData\\Local/renv/cache/R-3.5/v2"
renv:::renv_cache_list()
#> character(0)
library(magrittr)
fs::dir_ls(renv:::renv_paths_common(""))  %>%
  fs::dir_ls()
#> C:/Users/chris/AppData/Local/renv/R-3.5/binary
#> C:/Users/chris/AppData/Local/renv/R-3.5/bootstrap
#> C:/Users/chris/AppData/Local/renv/R-3.5/cache
#> C:/Users/chris/AppData/Local/renv/R-3.5/repos
#> C:/Users/chris/AppData/Local/renv/source/rcmdcheck
#> C:/Users/chris/AppData/Local/renv/source/remotes
#> C:/Users/chris/AppData/Local/renv/source/renv
#> C:/Users/chris/AppData/Local/renv/source/skeleton

Created on 2019-04-06 by the reprex package (v0.2.1.9000)

As you see above renv:::renv_paths_cache() path does not exist. I have renv/R-3.5 and renv/source and not renv/cache

Something has changed I guess...

how should renv_dependencies() handle missing packages?

This concerns the use of renv::init() for a brand new project.

Suppose you have a project that depends on dplyr; however, for some reason your user library is missing the dependency tibble. In this case, we see output like the following:

> deps <- renv:::dependencies()
> deps
                            Source Package Require Version
1 /Users/kevin/scratch/oops/deps.R   dplyr

> str(renv:::renv_dependencies(".", deps$Package))
List of 19
 $ tidyselect: chr "~/Library/R/3.5/library/tidyselect"
 $ R6        : chr "~/Library/R/3.5/library/R6"
 $ magrittr  : chr "~/Library/R/3.5/library/magrittr"
 $ assertthat: chr "~/Library/R/3.5/library/assertthat"
 $ graphics  : chr "/Library/Frameworks/R.framework/Resources/library/graphics"
 $ tools     : chr "/Library/Frameworks/R.framework/Resources/library/tools"
 $ plogr     : chr "~/Library/R/3.5/library/plogr"
 $ glue      : chr "~/Library/R/3.5/library/glue"
 $ utils     : chr "/Library/Frameworks/R.framework/Resources/library/utils"
 $ dplyr     : chr "~/Library/R/3.5/library/dplyr"
 $ tibble    : logi NA
 $ grDevices : chr "/Library/Frameworks/R.framework/Resources/library/grDevices"
 $ Rcpp      : chr "~/Library/R/3.5/library/Rcpp"
 $ stats     : chr "/Library/Frameworks/R.framework/Resources/library/stats"
 $ methods   : chr "/Library/Frameworks/R.framework/Resources/library/methods"
 $ rlang     : chr "~/Library/R/3.5/library/rlang"
 $ pkgconfig : chr "~/Library/R/3.5/library/pkgconfig"
 $ BH        : chr "~/Library/R/3.5/library/BH"
 $ purrr     : chr "~/Library/R/3.5/library/purrr"

> renv::init()
* Discovering package dependencies ... Done!
* Copying packages into the cache ... Done!
* Resolving missing dependencies  ...
Retrieving 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.5/tibble_2.1.1.tgz' ...
        OK [downloaded 310.6 Kb in 0.1 secs]
Installing crayon [1.3.4] ...
        OK (linked cache)
Installing cli [1.1.0] ...
        OK (linked cache)
Installing fansi [0.4.0] ...
        OK (linked cache)
Installing utf8 [1.1.4] ...
        OK (linked cache)
Installing pillar [1.3.1] ...
        OK (linked cache)
Installing tibble [2.1.1] from CRAN ...
        OK (installed binary)
* Lockfile written to '~/scratch/oops/renv.lock'.
* renv activated -- please restart the R session.

So, renv is able to recover and automatically download and install tibble, which is helpful. Some questions:

Suppose a version of tibble was installed in the cache. In what situations can we use it? We could:

  • Just use the newest version of tibble;
  • Use a version from the cache if it matches the latest version available on CRAN;
  • Use a version from the cache if it's equal to, or newer, than the version on CRAN;
  • Ask the user?

iron down semantics of init() in different contexts

hadley [9:37 AM]

  1. No lockfile + no package library -> discover package dependencies, install them, reload
  2. Lockfile + no package library -> restore the project from the lockfile, reload
  3. Anything else - ask whether you want 1 or 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.