Dear fellow package developers,
I recently came across
source("https://install-github.me/MangoTheCat/goodpractice")
which seems very elegant to write into a github package readme as installation instructions.
That way, people wanting to simply use a package can avoid installing devtools with all its dependencies.
It is also a bit more concise than:
if(!requireNamespace("devtoools", quietly=TRUE)) install.packages("devtoools")
devtools::install_github("MangoTheCat/goodpractice")
And it (seems to) work for any github repo, so no drat [1] setup on the side of the package maintainer is needed.
I had never seen this before (probably just missed it) and install-github.me only shows "coming soon".
So I wonder:
- is this safe to use and platform compatible?
- why isn't it more common?
- are there yet better alternatives?
- do I miss something obvious?
Thanks ahead for thoughts and opinions,
Berry
[1] https://github.com/eddelbuettel/drat
[R-pkg-devel] installing packages from github
3 messages · Berry Boessenkool, Gábor Csárdi, Dirk Eddelbuettel
Disclaimer: I built install-github.me. More below. On Mon, Sep 4, 2017 at 3:22 PM, Berry Boessenkool
<berryboessenkool at hotmail.com> wrote:
[...]
I had never seen this before (probably just missed it) and install-github.me only shows "coming soon". So I wonder: - is this safe to use and platform compatible?
I am not sure what you mean by safe. It is just the collated R files of https://github.com/r-lib/remotes, you can also read the code if you are concerned: https://install-github.me/MangoTheCat/goodpractice It should work on all platforms, please report bugs if it fails for you.
- why isn't it more common?
I can't fully answer that, but at least partly because I am not promoting it, and the r-lib team is not promoting it, either. I believe that this is because we don't have consensus on whether it is a good idea to teach people to source "random" code from the web.
- are there yet better alternatives?
Better in what way?
- do I miss something obvious?
I don't think so. :) Best, Gabor
Thanks ahead for thoughts and opinions, Berry
[...]
On 4 September 2017 at 14:22, Berry Boessenkool wrote:
| - do I miss something obvious?
The part where devtools has been undergoing a renovation for some time now
splitting functionality into many small packages?
I have my own views on repos with clearly marked and explicitly prepared
releases versus 'installing random commit snapshots from GH' -- but sometimes
you need the latter and I tend to use the helper below at the shell prompt.
It switches to using remotes quite some time ago.
Dirk
#!/usr/bin/env r
#
# A simple example to install one or more packages from GitHub
#
# Copyright (C) 2014 - 2016 Carl Boettiger and Dirk Eddelbuettel
#
# Released under GPL (>= 2)
## load docopt and remotes (or devtools) from CRAN
suppressMessages(library(docopt)) # we need docopt (>= 0.3) as on CRAN
suppressMessages(library(remotes)) # can use devtools as a fallback
## configuration for docopt
doc <- "Usage: installGithub.r [-h] [-x] [-d DEPS] [-u UPDATE] [REPOS...]
-d --deps DEPS install suggested dependencies as well? [default: NA]
-u --update UPDATE update dependencies? [default: TRUE]
-h --help show this help text
-x --usage show help and short example usage"
opt <- docopt(doc) # docopt parsing
if (opt$usage) {
cat(doc, "\n\n")
cat("where REPOS... is one or more GitHub repositories.
Examples:
installGithub.r RcppCore/RcppEigen
installGithub.r is part of littler which brings 'r' to the command-line.
See http://dirk.eddelbuettel.com/code/littler.html for more information.\n")
q("no")
}
## docopt parsing
opt <- docopt(doc)
if (opt$deps == "TRUE" || opt$deps == "FALSE") {
opt$deps <- as.logical(opt$deps)
} else if (opt$deps == "NA") {
opt$deps <- NA
}
opt$update <- as.logical(opt$update)
invisible(sapply(opt$REPOS, function(r) install_github(r, dependencies = opt$deps, upgrade = opt$update)))
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org