renv.lock logging global packages as well

I am new to renv and setting up project environments in R.
I want specific version of certain libraries in my renv.lock() and here's the workflow that I am using:

  1. Initialising an environment.
  2. Loading my packages.
  3. Snapshot.
library(renv)
renv::init()

library(lidR)
library(tidyverse)
library(GGally)
library(tidymodels)
library(randomForest)
library(patchwork)
library(stringr)
library(caret)

renv::snapshot()

But the generated lock file contains all global packages also, which I don't want in my lock file.

renv includes the packages you use, as well as their recursive dependencies, within the lockfile. So:

library(renv)

packages <- c(
  "lidR",
  "tidyverse",
  "GGally",
  "tidymodels",
  "randomForest",
  "patchwork",
  "stringr",
  "caret"
)

deps <- tools::package_dependencies(packages, recursive = TRUE)
sort(unique(unlist(deps)))

gives a total of 177 recursive package dependencies.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.