Compare two renv projects

I am using two projects that over time have differed in packages and tools but initially were intended to be the same, or at least have the same version of some core packages.
Is there an easy way to compare the renv.lock file from within R (or renv)?

I tried with diff but the output show also differences in the hash, with renv_lockfile_read I can read the file but the comparison via diffObj doesn't work well to highlight the differences.

There is likely a more elegant approach but this works, as a renv is just a JSON it can be read in, if you are only interested in package and version then this gives you that in a tibble

library(jsonlite)
library(tidyverse)
my_renvlock <- fromJSON("renv.lock")

map_dfr(my_renvlock$Packages, ~ enframe(.) |>
  filter(name %in% c("Package", "Version")) |>
  mutate(value = as.character(value)) |>
  pivot_wider())
1 Like

Many thanks, I'll explore this method

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.