executing-plans
executing-plans
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available
manage-renv-dependenciesManage R package dependencies using renv for reproducible environments. Covers initialization, snapshot/restore workflow, troubleshooting common issues, and CI/CD integration. Use when initializing dependency management for a new R project, adding or updating packages, restoring an environment on a new machine, troubleshooting restore failures, or integrati…
Independent GitHub snapshot · Automated classification · Original documentation governs
Set up and maintain reproducible R package environments using renv.
renv.lock file (for restore)renv::init()
This creates:
renv/ directory (library, settings, activation script)renv.lock (dependency snapshot).Rprofile to activate renv on loadGot: Project-local library created. renv/ directory and renv.lock present. .Rprofile updated with activation script.
If fail: Hangs? Check network connectivity. Fails on specific package? Install that package manually first with install.packages() then rerun renv::init().
Install packages as usual:
install.packages("dplyr")
renv::install("github-user/private-pkg")
Then snapshot to record state:
renv::snapshot()
Got: renv.lock updated with new packages and versions. renv::status() shows no out-of-sync packages.
If fail: renv::snapshot() reports validation errors? Run renv::dependencies() to check which packages actually used, then renv::snapshot(force = TRUE) to bypass validation.
renv::restore()
Got: All packages installed at exact versions in renv.lock.
If fail: Common issues: GitHub packages fail (set GITHUB_PAT in .Renviron), system dependencies missing (install with apt-get on Linux), timeouts on large packages (set options(timeout = 600) before restore), binaries not available (renv compiles from source. Ensure build tools installed).
# Update a specific package
renv::update("dplyr")
# Update all packages
renv::update()
# Snapshot after updates
renv::snapshot()
Got: Target packages updated to latest compatible versions. renv.lock reflects new versions after snapshot.
If fail: renv::update() fails for specific package? Try installing directly with renv::install("package@version") then snapshot.
renv::status()
Got: "No issues found" or clear list of out-of-sync packages with actionable guidance.
If fail: Status reports packages used but not recorded? Run renv::snapshot(). Packages recorded but not installed? Run renv::restore().
.Rprofile for Conditional Activationif (file.exists("renv/activate.R")) {
source("renv/activate.R")
}
Ensures project works even if renv isn't installed (CI environments, collaborators).
Got: R sessions activate renv automatically when starting in project directory. Sessions without renv installed still start without errors.
If fail: .Rprofile causes errors? Ensure file.exists() guard present. Never call source("renv/activate.R") unconditionally.
Track these files:
renv.lock # Always commit
renv/activate.R # Always commit
renv/settings.json # Always commit
.Rprofile # Commit (contains renv activation)
Ignore these (already in renv's .gitignore):
renv/library/ # Machine-specific
renv/staging/ # Temporary
renv/cache/ # Machine-specific cache
Got: renv.lock, renv/activate.R, renv/settings.json tracked by Git. Machine-specific directories (renv/library/, renv/cache/) ignored.
If fail: renv/library/ accidentally gets committed? Remove with git rm -r --cached renv/library/ and add to .gitignore.
In GitHub Actions, use renv cache action:
- uses: r-lib/actions/setup-renv@v2
Automatically restores from renv.lock with caching.
Got: CI pipeline restores packages from renv.lock with caching enabled. Subsequent runs faster due to cached packages.
If fail: CI restore fails? Check renv.lock is committed and up to date. For private GitHub packages, ensure GITHUB_PAT set as repository secret.
renv::status() reports no issuesrenv.lock committed to version controlrenv::restore() works on clean checkout.Rprofile conditionally activates renvrenv.lock for dependency resolutionrenv::init() in wrong directory: Always verify getwd() firstrenv::init(), only use project libraryrenv::snapshot()--vanilla flag: Rscript --vanilla skips .Rprofile, so renv won't activaterenv.lock designed to be diffable JSONrenv::install("bioc::PackageName") and ensure BiocManager configuredcreate-r-package - includes renv initializationsetup-github-actions-ci - CI integration with renvsubmit-to-cran - dependency management for CRAN packages