From 635439754cdb25f10abf22d58dc65875dab23330 Mon Sep 17 00:00:00 2001 From: Sarah Stevens Date: Tue, 24 Mar 2026 10:23:40 -0500 Subject: [PATCH 1/6] small edits to episode 3 library loading --- episodes/03-reproducible-dev-environment.md | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/episodes/03-reproducible-dev-environment.md b/episodes/03-reproducible-dev-environment.md index 73b11cef..f96e4573 100644 --- a/episodes/03-reproducible-dev-environment.md +++ b/episodes/03-reproducible-dev-environment.md @@ -249,10 +249,15 @@ renv::install("my_package") Let's install the packages we need for this script. At this time, we need `jsonlite`, `lubridate` and `ggplot2`. ```r -renv::install("jsonlite", "lubridate", "ggplot2"), +renv::install("jsonlite", "lubridate", "ggplot2") ``` -I can also install packages in any of the usual ways, i.e., `install.packages()` or `pak::pkg_install("ggplot2")`, but you'll have to complete an additional step to update the `lock` file enumerating packages and dependencies. A call to `renv::snapshot()` should suffice. +We can also install packages in any of the usual ways, i.e., `install.packages()` or `pak::pkg_install("ggplot2")` and `renv` will intercept and install it in the environment. +Then we need to run the `snapshot()` function to update the `renv.lock` file with all the packages installed. + +```r +renv::snapshot() +``` Now we can open the `renv.lock` file and see that it stores a lot of machine-readable information in plain text. However, you could also COMMAND+F (MacOS) or CTRL+F (Windows) to double check that the packages installed are now listed. @@ -266,19 +271,26 @@ Let's delete the packages we just installed and then restore them using the exis remove.packages(c("jsonlite", "lubridate", "ggplot2")) ``` + If you attempt to load these packages now, your get an error ```r -library("jsonlite) +library("jsonlite") ``` +::::::::::::::: instructor + +If the call to load `jsonlite` succeeds they might need to restart the R session because they loaded it previously and it is cached. + +::::::::::::::::::::::::::: + ```output Error in library(jsonlite) : there is no package called ‘jsonlite’ ``` To restore the packages from the `renv.lock`, ```r -renv::restore("renv.lock") +renv::restore() ``` If you attempt to load these packages now, it will work! From 321d7731b872b20f4f68616a09c360636f02baff Mon Sep 17 00:00:00 2001 From: Sarah Stevens Date: Tue, 24 Mar 2026 12:23:55 -0500 Subject: [PATCH 2/6] Removing accidental bold --- episodes/03-reproducible-dev-environment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/episodes/03-reproducible-dev-environment.md b/episodes/03-reproducible-dev-environment.md index f96e4573..347d0fbd 100644 --- a/episodes/03-reproducible-dev-environment.md +++ b/episodes/03-reproducible-dev-environment.md @@ -371,7 +371,7 @@ We are now setup to run our code from the newly created R project ```bash -(venv_spacewalks) $ **Rscript eva_data_analysis.R** +(venv_spacewalks) $ Rscript eva_data_analysis.R ``` From 626f0142958a512bbaad8805d87c3471cddc8977 Mon Sep 17 00:00:00 2001 From: Sarah Stevens Date: Tue, 24 Mar 2026 12:25:48 -0500 Subject: [PATCH 3/6] swtiching venv to renv for ignoring folder --- episodes/03-reproducible-dev-environment.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/episodes/03-reproducible-dev-environment.md b/episodes/03-reproducible-dev-environment.md index 347d0fbd..24b7e11e 100644 --- a/episodes/03-reproducible-dev-environment.md +++ b/episodes/03-reproducible-dev-environment.md @@ -301,11 +301,11 @@ library("jsonlite) ### Ignoring files -Note that you only need to share the small `renv.lock` file with your collaborators - and not the entire `venv_spacewalks` directory with packages contained in your virtual environment. -We need to tell git to ignore that directory, so it is not tracked and shared - we do this by adding `venv_spacewalks` to the `.gitignore` in the root directory of our project. +Note that you only need to share the small `renv.lock` file with your collaborators - and not the entire `renv` directory with packages contained in your virtual environment. +We need to tell git to ignore that directory, so it is not tracked and shared - we do this by adding `renv` to the `.gitignore` in the root directory of our project. ```bash -(venv_spacewalks) $ echo "venv_spacewalks/" >> .gitignore +$ echo "renv/" >> .gitignore ``` If you are a MacOS user, remember the `.DS_Store` hidden file which is also not necessary to share with our project? We can tell git to ignore it by adding it on a new line in `.gitignore` as pattern `**/.DS_Store` (so it will be ignored in any sub-folder of our project). From c1bcffbf6e7578f0dd15e252e077ba19cf2e27b2 Mon Sep 17 00:00:00 2001 From: Sarah Stevens Date: Tue, 24 Mar 2026 12:27:35 -0500 Subject: [PATCH 4/6] another fix to renv --- episodes/03-reproducible-dev-environment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/episodes/03-reproducible-dev-environment.md b/episodes/03-reproducible-dev-environment.md index 24b7e11e..2850d5a9 100644 --- a/episodes/03-reproducible-dev-environment.md +++ b/episodes/03-reproducible-dev-environment.md @@ -323,7 +323,7 @@ Let's add and commit our updated `.gitignore` to our repository. ```bash (venv_spacewalks) $ git add .gitignore -(venv_spacewalks) $ git commit -m "Ignore venv folder and DS_Store file" +(venv_spacewalks) $ git commit -m "Ignore renv folder and DS_Store file" ``` The same method can be applied to ignore various other files that you do not want git to track. From af368639f12a15368a2d8319831a6fcd897abd0d Mon Sep 17 00:00:00 2001 From: Sarah Stevens Date: Tue, 24 Mar 2026 13:05:51 -0500 Subject: [PATCH 5/6] adding the lock file to the repo --- episodes/03-reproducible-dev-environment.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/episodes/03-reproducible-dev-environment.md b/episodes/03-reproducible-dev-environment.md index 2850d5a9..cdf03099 100644 --- a/episodes/03-reproducible-dev-environment.md +++ b/episodes/03-reproducible-dev-environment.md @@ -322,13 +322,23 @@ echo "**/.DS_Store" >> .gitignore Let's add and commit our updated `.gitignore` to our repository. ```bash -(venv_spacewalks) $ git add .gitignore -(venv_spacewalks) $ git commit -m "Ignore renv folder and DS_Store file" +$ git add .gitignore +$ git commit -m "Ignore renv folder and DS_Store file" ``` The same method can be applied to ignore various other files that you do not want git to track. +### Adding the lock file to the repo + +We should also add our lock file to the repository so anyone who uses the repo going forward can rebuild our environment. + +```bash +$ git add renv.lock +$ git commit -m "Adding renv.lock file" +``` + + :::::::::::::::::::::: callout ### Another challenge in (long-term) reproducibility From 48b89c256ced2db0ddcece584df363f60e59d97c Mon Sep 17 00:00:00 2001 From: Sarah Stevens Date: Tue, 24 Mar 2026 13:16:09 -0500 Subject: [PATCH 6/6] removing python venv in prompt --- episodes/03-reproducible-dev-environment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/episodes/03-reproducible-dev-environment.md b/episodes/03-reproducible-dev-environment.md index cdf03099..b5f4b647 100644 --- a/episodes/03-reproducible-dev-environment.md +++ b/episodes/03-reproducible-dev-environment.md @@ -381,7 +381,7 @@ We are now setup to run our code from the newly created R project ```bash -(venv_spacewalks) $ Rscript eva_data_analysis.R + $ Rscript eva_data_analysis.R ```