capsule icon indicating copy to clipboard operation
capsule copied to clipboard

workflow/option to install packages locally

Open njtierney opened this issue 4 years ago • 7 comments

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?

njtierney avatar Oct 25 '21 00:10 njtierney

Actually would

renv::hydrate()

Just do this?

njtierney avatar Oct 26 '21 05:10 njtierney

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!

MilesMcBain avatar Oct 26 '21 05:10 MilesMcBain

If this is what you want, happy to wrap it up in its own function.

MilesMcBain avatar Oct 26 '21 05:10 MilesMcBain

That would be amazing!

njtierney avatar Oct 26 '21 07:10 njtierney

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 packages is zero length renv::restore appears 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.

MilesMcBain avatar Oct 28 '21 06:10 MilesMcBain

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.

MilesMcBain avatar Nov 03 '21 06:11 MilesMcBain

Example:

image

MilesMcBain avatar Nov 09 '21 04:11 MilesMcBain