Repository navigation
Description
Motivation
Writing the renv-to-rig tutorial in #470 exposed how much of the migration users currently have to coordinate themselves. Would a rig proj renv migrate command be useful? This issue proposes follow-up CLI work; the linked PR adds documentation only.
The existing import converts exact versions to compatible-version requirements, does not retain package-source information, and leaves renv startup activation in place. A migration command could handle those steps as part of a supported transition.
A small user-facing interface could be:
rig proj renv migrate --dry-run
rig proj renv migrateThe preview would show the dependency conversion, startup-file edits, installation plan, and any unsupported sources or conflicting configuration. The migration would then:
- Use the existing
renv.lockas its input, preserving exact R and package versions and translating supported package sources. Stop with an explanation if a source cannot be represented faithfully, rather than silently substituting a package from another source. - Resolve and install the rig environment, reporting any differences or failures before completing the startup handoff.
- Back up the startup files it changes and replace renv activation with rig's library setup, preserving unrelated settings. Retain
renv.lock, the old project library, and renv's global cache. - Report what changed, how to recover the previous setup, which R version the editor needs to use, and how to check the environment. Users would still run their own analysis or tests to establish that results match.
Migration should not automatically snapshot the current renv library: choosing whether the installed environment or the existing lock file represents the intended state belongs to the user. It should also keep migration separate from package upgrades.
How would this differ from import?
rig proj renv import already creates a manifest and startup boilerplate, so it is more than a file converter. However, treating another project's lock file as dependency input is a different intent from replacing the environment manager of a working project. Keeping separate commands would make those side effects explicit:
| Responsibility | rig proj renv import |
Proposed rig proj renv migrate |
|---|---|---|
| Purpose | Bring dependency declarations into a rig project. | Switch a working renv project to rig. |
| Version policy | Make preserving exact versions versus importing compatible ranges an explicit choice. | Preserve exact versions by default. |
| Package sources | Translate supported sources or report what cannot be imported. | Require faithful translation before proceeding. |
| Resolve and install | Leave these as separate operations. | Include locking and syncing in the migration. |
| renv activation | Leave the existing activation alone. | Manage the startup handoff with safeguards. |
| Recovery | Refuse accidental overwrites. | Back up changed startup files and retain the old environment. |
The version-policy and source-handling entries above are suggested improvements to import, not descriptions of its current behavior. Source translation should be shared by both commands: users should not have to choose migrate to avoid losing a Git or private-repository source. An exact-version import option could support the same preservation policy without changing the existing compatible-range default.
The aim would be to automate the mechanical migration steps while leaving project-specific decisions and validation visible.
Activity
Import repositories from renv.lock.
Import repositories from renv.lock.
Import git-based package sources from renv.lock.
Add an --exact-versions flag to 'rig proj renv import'.
gaborcsardi commentedon Nov 11, 2026
Thanks for writing this up! I think we already have some improvements in the recent PRs, in that we now 1) import repositories better and 2) import package versions exactly into
rproj.lock, including packages from git repos.I would prefer avoiding a new command, and rather make the existing
importwork better. Maybe we can add a new--migrateoption to that, or make the new behavior the default and have a new opt-out option that only does what the currentimportdoes, essentially point 1. in your sequence above.I think it is mostly straightforward to implement this, except that recovery seems hard. E.g. should we back up the renv package library? Do we need to do that at all for a quick recovery? Doesn't renv use symlinks there that can be recovered very quickly? Is it our job to recover the project files, or should we rely on
gitto do that? If yes, then what do we do if the project does not use git, or git is not available?For now I am leaning towards a minimal approach for recovery. E.g. telling people to back up their project. I can be convinced to do more, though.
Btw. let's keep an eye on #470 while improving this.