workflow/option to install packages locally
Basically I would like something like capsule::reproduce_lib() but that installs the packages locally for interactive use outside of the capsule::run workflow.
Perhaps the function could be called:
install_lockfile_pkgs() or something?
Actually would
renv::hydrate()
Just do this?
I dont think so... I think that tries to discover your deps from your code.
The subtle issue that arises is that the lockfile versions may not be compatible with your local library due to being outdated. I.e. the version may be below the min version of other dependent installed packages. With your local library, the only safe direction to move is forward to install the latest.
So if you do this:
capsule::get_pkg_behind_capsule()$name |> install.packages()
I think that will install the latest versions of packages that are behind the lockfile or not present. This would ensure you are at or in front of the lockfile versions.
edit: need the $name!
If this is what you want, happy to wrap it up in its own function.
That would be amazing!
Notes for myself mostly:
I think this kind of thing should be what solves this: renv::restore(packages = capsule::get_pkg_behind_capsule()$name, prompt = FALSE)
A few issues a present:
- if
packagesis zero lengthrenv::restoreappears to ignore it and do a regular restore, which can downgrade your lib. Need guard rails to stop that from happening. -
capsule::get_pkg_behind_capsule()only considers the declared deps, not all the recursive deps. For this to work it needs to be able to consider the complete set.get_project_deps(detect_dependencies(dep_source_paths))should do it.
Have a try of capsule::dev_mirror_lockfile().
Which does not infact mirror the lockfile. It makes sure all deps are at least the lockfile versions, the ones ahead are not touched. So... it's kind of like a funhouse mirror.
Example:
