Skip to content

Import repositories from renv.lock - #472

Open
atheriel wants to merge 1 commit into
mainfrom
aj-renv-import-repos
Open

atheriel wants to merge 1 commit into
mainfrom
aj-renv-import-repos

Conversation

@atheriel

Copy link
Copy Markdown
Contributor

rig proj renv import now reads the package repositories of an renv.lock and turns them into [[repository]] entries, instead of leaving every package to resolve from the built-in CRAN. We also make an effort to map known CRAN and Bioconductor aliases to the built-in ones, and turn off these built-in repositories if the renv.lock in question doesn't use them (which matches how renv behaves).

In addition, we now warn when packages from other sources (e.g. GitHub, GitLab, local) will need manual adjustment.

This is progress towards some of the issues raised in #471.

Unit tests are included.

@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.19955% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.44%. Comparing base (be45961) to head (6631e07).

Files with missing lines Patch % Lines
src/renv.rs 98.25% 23 Missing ⚠️
src/rproj.rs 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #472      +/-   ##
==========================================
+ Coverage   65.53%   66.44%   +0.91%     
==========================================
  Files          91       91              
  Lines       46973    48297    +1324     
==========================================
+ Hits        30784    32093    +1309     
- Misses      16189    16204      +15     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gaborcsardi

Copy link
Copy Markdown
Member

Thanks! I am skeptical about whether this is worth doing at all, because it seems to be impossible to do it correctly. E.g. if you have {"Name":"P3M","URL":"https://p3m.dev/cran/__linux__/noble/latest"} that is converted to a custom repo with explicit = true, but keeping the __linux/noble URL which is only correct for Noble and wrong everywhere else.

Maybe we should not try doing this at all, but rather just print out the repositories with a comment that they likely need adjustments.

Btw. the [[repository]] syntax needs some changes, to support plain CRAN-like repositories better, and we'll likely need to introduce repository types: repos with extended metadata, CRAN proper (with archived packages), plain CRAN-like repos, Bioconductor repos, R-universe repos, etc. Then it'll be even harder to this conversion.

@atheriel

Copy link
Copy Markdown
Contributor Author

I think it's important to try. Most of the groups promoting renv (that I know of) are using custom repositories for CRAN and Bioconductor.

I'll look more carefully at the binary path case, though. We should be able to detect it.

@atheriel
atheriel force-pushed the aj-renv-import-repos branch from 5d68cff to 6c6bccd Compare October 16, 2026 18:13
@atheriel

Copy link
Copy Markdown
Contributor Author

We now map p3m.dev and Linux binary URLs correctly.

`rig proj renv import` now reads the package repositories of an
renv.lock and turns them into `[[repository]]` entries, instead of
leaving every package to resolve from the built-in CRAN. We also make an
effort to map known CRAN and Bioconductor aliases to the built-in ones,
and turn off these built-in repositories if the `renv.lock` in question
doesn't use them (which matches how renv behaves).

In addition, we now warn when packages from other sources (e.g. GitHub,
GitLab, local) will need manual adjustment.

This is progress towards some of the issues raised in #471.

Unit tests are included.

Signed-off-by: Aaron Jacobs <aaron.jacobs@posit.co>
@atheriel
atheriel force-pushed the aj-renv-import-repos branch from 6c6bccd to 6631e07 Compare October 16, 2026 18:14
@gaborcsardi

Copy link
Copy Markdown
Member

I'll delay this a bit until we have worked out how exactly we should handle the different types of repositories. That'll also affect how we convert renv repositories to rig repositories. Soon.

This branch has not been deployed

No deployments
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.

2 participants