eddelbuettel/littler

Check if package installed already, if so, ignore

1beb opened this issue · 4 comments

1beb commented

I'm looking through the flags and I don't know if this is a feature. Basically, I have a long CI build process where some packages might already be installed. If so, I want to skip them.

Is there some flag to do this?

As I see it:

  • We call install.packages() and it does not have that feature. It installs what you tell it to.
  • Someone (you?) needs to add a second layer to intersect "all packages I told you about" with what installed.packages() (note the "ed") returns about the current system, and then proceeds with just the added packages.
  • You could probably write that in 30 or 60 minutes based off install.r or install2.r.
1beb commented

Appreciate that you ask rather than hacking blindly :)

I can see advantages to both. We kept the simple install.r around when @cboettig made really nice changes that became install2. (and I use the -l dir flag all the time). So we could add it there, or we could just add a new one installIfNew.r or something. No strong feelings really.

This is now the -s | --skipinstalled option for install2.r.

It no longer messages on null-ops. With multiple arguments it would do that on each one -- too noisy.

edd@rob:~/git/littler/inst/examples(master)$ ./install2.r -h
Usage: install2.r [-r REPO...] [-l LIBLOC] [-h] [-x] [-s] [-d DEPS] [--error] [--] [PACKAGES ...]

-r --repos REPO     repository to use, or NULL for file [default: getOption]
-l --libloc LIBLOC  location in which to install [default: /usr/local/lib/R/site-library]
-d --deps DEPS      install suggested dependencies as well [default: NA]
-e --error          throw error and halt instead of a warning [default: FALSE]
-s --skipinstalled  skip installing already installed packages [default: FALSE]
-h --help           show this help text
-x --usage          show help and short example usage 
edd@rob:~/git/littler/inst/examples(master)$ 
edd@rob:~/git/littler/inst/examples(master)$ ./install2.r -s xts digest    ## nothing to do here
edd@rob:~/git/littler/inst/examples(master)$