top | item 44006735

Show HN: Rv, a Package Manager for R

76 points| Keats | 9 months ago |github.com

We have been building a package manager for R inspired by Cargo in Rust. The main idea behind rv is to be explicit about the R version in use as well as declaring which dependencies are used in a rproject.toml file for a given project. There's no renv::snapshot equivalent, everything needs to be declared up front, the config file (and resulting lockfile) is the source of truth. This avoids issue where renv might miss information about the installation and is also easy to tweak some packages, eg install one from source and install suggests from another.

If you have used Cargo/npm/any Python package manager/etc, it will be very familiar.

31 comments

order

simpaticoder|9 months ago

You might want to consider writing a plugin for R with Mise en Place https://mise.jdx.dev/core-tools.html This would extend your reach and might take some of the heavy lifting out of the project. (At least for the runtime portion. I don't think it will help with package management.)

Keats|9 months ago

I could be wrong but I feel like the overlap between mise and R users is likely very tiny

xvilka|9 months ago

Maybe some code could be shared with the `uv`[1] to avoid re-implementing same things.

[1] https://github.com/astral-sh/uv

Keats|9 months ago

We actually do use a bit of their code for the linking phase, which they seem to have taken from Cargo. For the rest, Python and R are way too different in how they handle packages to allow sharing code.

condwanaland|9 months ago

Very cool! Are you planning for there to be a corresponding R package that exposes the high level commands? The popularity of the usethis package really showed the power of keeping people within the R interpreter rather than going back and forth with the terminal. This is so important for a language like R that has so many users without much CS training

arbutus8|9 months ago

Yes! Absolutely in the plans to have a corresponding R package. In the meantime, we've created a `.rv` R environment within rv projects that allow users to call things like `.rv$sync()` and `.rv$add("pkg")` from the console. Our internal user bases is primarily not CS based and have found these functions extremely helpful

badmonster|9 months ago

I'm curious — does rv support or plan to support per-project isolation of system-level dependencies (e.g., gfortran, libxml2, etc.) like what renv sometimes indirectly requires users to manage outside R? If not, do you have recommendations for managing these in a reproducible way alongside rv?

Keats|9 months ago

It's not planned for rv, this is whole other can of worms. Something like nix/docker should work but I'm not working on that part myself so I can't comment.

mauflows|9 months ago

I'm curious how your team ended up doing this. We settled on Nix with flakes after some pain with Docker / RStudio Server.

_Wintermute|9 months ago

My biggest issue with R package management is version pinning. If I specify an older version of a package, R will fetch the latest versions of all its dependencies, regardless if they're compatible or not, which leads to manually chasing down and re-installing specific versions of dependencies and sub-dependencies one-by-one.

Microsoft's CRAN time machine helped solved this, but I think they've recently shut it down and I don't really trust Posit to not have a version behind a paywall.

t-kalinowski|9 months ago

Posit offers something similar to Microsoft’s CRAN Time Machine, but it works not only for CRAN, but also for Bioconductor and PyPI. You can add a date to the Public Posit Package Manager URL to access a snapshot of all packages from that day.

For example: https://packagemanager.posit.co/cran/2025-03-02

You can browse available snapshot dates here: https://packagemanager.posit.co/client/#/repos/cran/setup?sn...

This also works for PyPI and Python packages: https://packagemanager.posit.co/pypi/2025-03-04/simple

arbutus8|9 months ago

You're hitting one of my (and many people's) main issue with the R package distribution system. In CRAN, only one package version is available at a time, which makes things like version pinning quite difficult. Now the benefit of that is that CRAN guarantees all packages will work together at any moment in time, but then trying to reach back into the Archive breaks that guarantee.

What the CRAN time machine (and now Posit Package Manager) does is take that compatibility guarantee, and freeze it so you have access to all the same, compatible, packages at any moment in time.

While I personally do use PPM fairly extensively, I do understand the paywall concern for long-term reproducibility so `rv` can help you here, with a bit of manual massaging. I'd recommend setting the repositories section of the config file to be a snapshot date in PPM that contains the package version(s) you're interested in and then installing using that repository (taking the benefit of that CRAN guarantee), then in both the config file and `rv.lock`, replace all the references to the PPM repo with your preferred CRAN mirror. This will allow you to resolve to compatible package versions, but then for your POSIT concern, will still be able to reproduce using the CRAN archive.

almostkindatech|9 months ago

Might be worth looking at groundhog, if you want a 'time machine' less likely to have a commercial motive

rorylawless|9 months ago

Ok, this is really promising. I've always found renv to be slightly frustrating to use and it ends up breaking in mysterious ways after a time. rv was a joy to use in a small personal repo.

j_bum|9 months ago

Looks interesting, I’m excited to give it a try.

Is there any plan to have it create a manifest (like renv.lock) that can be used directly with the posit publishing system?

arbutus8|9 months ago

Yes, that's a feature we are considering adding

xgstation|9 months ago

is using Rust to rewrite existing package managers a new trendy thing

feels we eagerly need cv -> C/C++ package manager

mbeavitt|9 months ago

Can this be used to effectively create R environments? I’m desperate for such a solution.

okanat|9 months ago

I used pixi for that. It uses Conda ecosystem but you get proper lockfiles and great native binary package support.

Keats|9 months ago

By default, rv will create a library folder in the same folder as your rproject.toml and there's rv activate/deactivate to add it to your loaded libs. Pretty much the same stuff as a virtualenv in Python.

pupperino|9 months ago

{renv} is pretty solid, I've been using it in production for years now and have no complaints.

goosedragons|9 months ago

You can do that with Nix or Guix.

scrappyjoe|9 months ago

Doesn’t renv do that? What need does renv not meet for you?

cluckindan|9 months ago

Is it possible to override transitive dependencies?

Keats|9 months ago

Yes, if you list it in the rproject.toml from a specific repo/url/git etc it will use that

barslmn|9 months ago

Can it be used for installing from bioconductor?

Keats|9 months ago

Not yet but it is on the radar.