Add functionality to ensure a package is installed without actually loading (and thus attaching) it.
phirsch opened this issue · 6 comments
Sometimes I want to ensure that a package is installed (and have it automatically installed if it is not), but I do not want to actually load it, for example because of name clashes.
Using pacman, I can currently only use p_load()
followed by p_unload()
, but since loading a package can have lasting side effects, I would prefer a clean single-step way to express and achieve this. A possible name for this function would be: p_ensure()
.
Please let me know if you would prefer a pull request to this effect.
Does p_isinstalled
not meet your needs?
https://github.com/trinker/pacman/blob/master/R/p_isinstalled.R
My point is that p_isinstalled()
would not automatically install a package if it is missing.
Much of the convenience and beauty of p_load()
stems from the fact that it allows to succinctly specify a dependency on a package you want to use (using just one single statement).
What I am looking for is something very similar - I want to state that I intend to use the package in what follows, yet I would like to do so without actually loading (and thus attaching) it.
Ah - I see now. Ok. That isn't something I've found the need for but can see how it could be useful in some situations. It would be easy enough to add. I guess the one thing to decide is what name to go with for the function.
p_ensure
could work but I think maybe something like p_install_if_not
or p_installifnot` might be more descriptive? Thoughts?
Side note: Looking at this makes me realize we weren't entirely consistent with our naming convention when it came to p_isinstalled
What about p_ensure_installed
or p_install_if_missing
?
An alternative would be to add a boolean flag like skip_if_installed
or reinstall
or update
to the p_install_xx
group of functions. This could help keep the combinatorial effect of adding a new function name which would have to be crossed with the _gh
and _version
suffixes in check.
This would be very useful. Think on a Dockerfile that is built upon another Docker image. Every time I add a package that is present on "father" image is installed twice making the process longer.
Install only if not present and don't load is exactly what I need