rstudio / renv

renv: Project environments for R.
https://rstudio.github.io/renv/
MIT License
996 stars 152 forks source link

Expect `renv` to recursively scour folders? #1838

Open rsangole opened 6 months ago

rsangole commented 6 months ago

Hello,

I work in a monorepo folder, setup as an R project (Contains an .Rproj). Within the monorepo, there are subfolders: many contain R packages, many contain R scripts.

My expectation for renv::init() in the root monorepo folder would be that it would scour through all the package sub-directories and script sub-directories, compile a comprehensive package dependency list and register them in the lock file.

However this isn't happening today. init() only creates an renv.lock with a minimal number of packages.

I also have a DESCRIPTION feel in the root directory, with a list of packages, but that doesn't help either:

Type: project
Description: foo
Depends:
    rsconnect
    arrow
    dplyr
    readr
    ...
    ...

Any ideas?

### Tasks
rsangole commented 6 months ago

One potential solution I found was to do this in a script in the main directory...

renv::snapshot(
    project = "folder-A/",
    lockfile = "renv.lock",
    prompt = TRUE,
    update = TRUE
)
renv::snapshot(
    project = "folder-B/",
    lockfile = "renv.lock",
    prompt = TRUE,
    update = TRUE
)
...
kevinushey commented 6 months ago

This should work. What is the output of renv::dependencies() in the monorepo root? Are any of these sub-folders .gitignored or something similar?

rsangole commented 6 months ago

None of the folders are in .gitignore.

The output of renv::dependencies() seems to be a large tibble:

image

Require and Version are all blank. Dev is all FALSE.

kevinushey commented 6 months ago

Thanks. Can you share the output you see from renv when you call renv::init() from the monorepo root?

The output of this might also be useful:

renv:::settings$snapshot.type()
renv:::renv_snapshot_dependencies(project = getwd())