Skip to content

Proposal: add rig proj renv migrate and improve renv import #471

Open

Description

@gadenbuie

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 migrate

The preview would show the dependency conversion, startup-file edits, installation plan, and any unsupported sources or conflicting configuration. The migration would then:

  1. Use the existing renv.lock as 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.
  2. Resolve and install the rig environment, reporting any differences or failures before completing the startup handoff.
  3. 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.
  4. 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

  1. added
    feature
    on Oct 16, 2026
  2. gaborcsardi commented on Nov 11, 2026

    @gaborcsardi
    Member

    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 import work better. Maybe we can add a new --migrate option to that, or make the new behavior the default and have a new opt-out option that only does what the current import does, 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 git to 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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions