lmu-osc / introduction-to-renv

Walkthrough tutorial on setting up and using renv
https://lmu-osc.github.io/introduction-to-renv/
Creative Commons Attribution Share Alike 4.0 International
1 stars 0 forks source link

Feedback Florian K. #24

Closed fkohrt closed 2 months ago

fkohrt commented 2 months ago

Overall, I found the introduction to renv to be very helpful and understandable! I have created one pull request each for both repos with smaller fixes (mostly typos: lmu-osc/introduction-to-renv#19 and lmu-osc/introduction-to-renv-exercises#3), feel free to accept or reject them. I have also created four issues (#20, #21, #22, #23) before creating this summary issue with all remaining (small) notes. But again, I deem it already a very worthwhile tutorial!

Background

Reproducibility

For example, requesting that someone install Python v3.8.2, R v4.0.3, and a specific version of a package is technically possible, but exceptionally tedious and a poor use of time time.

Technical definitions

By default, R will download packages from CRAN, but you can specify a different repository if you want to download a package from a different location. This is useful if you want to download a package from Bioconductor or GitHub, for example.

R Package Managers

These are also not managed by package managers, but can easily identified either by checking a package’s DESCRIPTION file or by checking out the Posit Package Manager page for the package.

{renv}

Quick start

File -> New Project -> New Directory -> New Project -> [x] Use renv with this project

Caching

In the context of {renv}, the apparent packages in the renv/library folder of your project are actually symlinks that point to the packages in the shared library!

Each project has its own library, located in the renv/library folder of the project, but the packages in this folder are actually symlinks to the packages in the shared library.

Exercises > Explicitly Record

  1. Check the status of the dependencies by running renv::status().
    • Is the lock file in-sync with the project library? Why not?

During this step I get "No issues found -- the project is in a consistent state."

Therefore, running renv::restore(), as is suggested next, leads to "The library is already synchronized with the lockfile."

Rendering then fails due to the missing maps package, which I add to the lock file using renv::record("maps"). Only then the renv::restore() installs the missing package.

Also, now I'm warned that the project is out of sync due to the {maps} package that is recorded but seemingly not used. Is it supposed to be warn me? From the documentation I gather that the recommended way is to create a file called _dependencies.R with library() calls.

Optional content > embed() and use()

This is a trade-off that you will need to consider when deciding whether to use renv::embed() or renv::use().

Open questions

I really liked it when you explained the three columns reported by renv::status() in {renv} > Starting Details > Status and Snapshot > Status.

NeuroShepherd commented 2 months ago

Is it possible to install a package from GitHub using install.packages()? Maybe rather use r-universe as a second example.

Yes, packages can be installed from any weblink. The renv::install() function just simplifies this quite a bit.

I wondered whether you want to add a few words how install.packages() is altered in a repo which is controlled by renv?

I think explaining that {renv} shims install.packages() with renv::install() is probably better left unsaid for the tutorial.

NeuroShepherd commented 2 months ago

Shouldn't this read something like "whether to use renv::embed() or a lockfile"?

Ope, yes this should!

NeuroShepherd commented 2 months ago

During this step I get "No issues found -- the project is in a consistent state."

I've corrected this. I originally had the exercise set-up slightly differently, but did not update this text.

Rendering then fails due to the missing maps package, which I add to the lock file using renv::record("maps"). Only then the renv::restore() installs the missing package.

The rendering failure is intentional! I want people to go through precisely these steps.

fkohrt commented 2 months ago

Maybe I missed it, but what was your answer to this?

Also, now I'm warned that the project is out of sync due to the {maps} package that is recorded but seemingly not used. Is it supposed to be warn me? From the documentation I gather that the recommended way is to create a file called _dependencies.R with library() calls.

I'm also asking because I'm interested to hear your thoughts on it.

NeuroShepherd commented 2 months ago

Maybe I missed it, but what was your answer to this?

Also, now I'm warned that the project is out of sync due to the {maps} package that is recorded but seemingly not used. Is it supposed to be warn me? From the documentation I gather that the recommended way is to create a file called _dependencies.R with library() calls.

I'm also asking because I'm interested to hear your thoughts on it.

I made some relevant edits in the renv-exercises repo which haven't been integrated yet.

I'm indifferent on the creation of a _dependencies.R file. One can accomplish the same thing by just including a library() call at the top of the relevant script.

fkohrt commented 2 months ago

I made some relevant edits in the renv-exercises repo which haven't been integrated yet.

Ah, I see.

I'm indifferent on the creation of a _dependencies.R file. One can accomplish the same thing by just including a library() call at the top of the relevant script.

Alright, just wondered whether you had in mind an entirely different way of handling this.