Skip to content

Renv export#441

Open
Keats wants to merge 3 commits intomainfrom
renv-export
Open

Renv export#441
Keats wants to merge 3 commits intomainfrom
renv-export

Conversation

@Keats
Copy link
Copy Markdown
Collaborator

@Keats Keats commented Apr 10, 2026

> renv::lockfile_validate(lockfile = "renv.lock") 
[1] TRUE

@Keats Keats marked this pull request as ready for review April 10, 2026 08:55
@Keats Keats requested a review from Copilot April 10, 2026 08:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an rv export renv workflow to generate an renv.lock-compatible JSON lockfile from an existing rv project (config + rv lockfile), including snapshot-based tests to validate the exported structure.

Changes:

  • Implement to_renv_lock() conversion from Lockfile + Config to a serializable RenvLock (including Git/GitHub/Local sources).
  • Add rv export renv --output <path> CLI subcommand that writes the exported renv.lock JSON and surfaces mapping warnings.
  • Extend Lockfile/public exports and add an insta snapshot test for the exported lockfile.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/renv.rs Adds renv lock export conversion logic and snapshot tests.
src/cli/commands/export.rs New CLI command implementation for exporting renv.lock.
src/cli/commands/mod.rs Wires new export command module into the CLI command set.
src/cli/mod.rs Re-exports the new export_renv command.
src/main.rs Adds Export -> Renv CLI plumbing and output formatting for warnings.
src/lockfile.rs Adds getters needed by the exporter (packages(), r_version_string()).
src/lib.rs Re-exports LockedPackage for use by the renv exporter.
src/snapshots/rv__renv__tests__renv_export.snap Snapshot for the exported renv.lock JSON.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/renv.rs Outdated
Comment thread src/renv.rs
Comment thread src/cli/commands/export.rs Outdated
@dpastoor
Copy link
Copy Markdown
Member

My biggest question/concern is going to be around git handling and mapping it to renv such that renv itself properly restores the correct version.

There is a specific edge case we hit in my vibe'd code as well of runiverse repos, since runiverse doesn't maintain an archive, it also inserts the git repo information to restore from there, so we should be able to support that. Anne hit that trying to export a shiny app to deploy to connect and then connect/renv/packrat couldn't find and restore that repo.

Could we add a couple e2e test that do the full export to a renv lock, then allow renv to attempt to restore the packages and confirm that the restoration does match the expected package version. I think those could live in a separate area of e2e that gets run either manually or on some trigger only if code in specific file(s) changes since hopefully we kinda lock this code in and don't need to change it often/ever after

@Keats
Copy link
Copy Markdown
Collaborator Author

Keats commented Apr 10, 2026

 Bash(Rscript -e '                                                                                                
      lib <- file.path(tempdir(), "renv_test_lib")                                                                 
      dir.create(lib, showWarnings = FALSE)                                                                        
      renv::restore(library = lib)                                                                                 
      cat("osinfo:", as.character(packageVersion("osinfo", lib.loc = lib)), "\n")                                  
      cat("renv:", as.character(packageVersion("renv", lib.loc = lib)), "\n")                                      
      ' 2>&1)                                                                                                      
  ⎿  The following package(s) will be updated:                                                                     

     # CRAN -----------------------------------------------------------------------                                
     - renv     [* -> 1.2.0]
                                                                                                                   
     # r-universe -----------------------------------------------------------------
     - osinfo   [* -> 0.0.1]                                                                                       
                                                                                                                 
     # Installing packages --------------------------------------------------------                              
     ✔ osinfo 0.0.1                             [copied from cache]                                                
     ✔ renv 1.2.0                               [copied from cache]                                                
     Successfully installed 2 packages in 8.9 milliseconds.                                                        
     osinfo: 0.0.1                                                                                                 
     renv: 1.2.0                                                                                                   

where os-info is from our r-universe repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants