Skip to content

Instantly share code, notes, and snippets.

@sebkopf
Last active March 31, 2017 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebkopf/3cf82afb2e535e92f2cfcf3e66d48475 to your computer and use it in GitHub Desktop.
Save sebkopf/3cf82afb2e535e92f2cfcf3e66d48475 to your computer and use it in GitHub Desktop.

The latest version of the devtools package on CRAN (version 1.12.0) has a bug that causes issues with the installation of package dependencies on Windows, which usually manifest as errors during the installation of GitHub packages stating some dependency (e.g. stringi or dplyr or htmltools, etc. package missing). The issue is described in various bug reports and was fixed in December 2016 (devtools issue #1409). However, as of March 2017, this bug fix has not propagated to the version of devtool on CRAN yet. The easiest solution is to use the fixed devtools from GitHub (this specific commit fixes the problem) for the installation of GitHub packages. Windows may not allow installation of a GitHub version of devtools using devtools (because it cannot overwrite the loaded package), in which case the easiest approach is to use the build_github_devtools function which always uses the latest GitHub development version of devtool (unfortunately does not support building specific commits but it will include the December commit that fixes the problem but, though unlikely, may also have unforseen issues since it is in active development). The full work-around is outlined below. As soon as CRAN updates to version 1.13 of devtools this workaround should no longer be necessary (and build_github_devtools function is no longer included in devtools).

# install CRAN version 1.12.0
install.packages("devtools") 

# use CRAN version to install newer GitHub version 1.12.0.9000
devtools::install_github("hadley/devtools", ref = "1ce84b04568ff7846c3da754f28e7e22a23c8737") 

#######
# IF the above command fails (ERROR: loading fails), use the following (Windows only)
# build the development version of devtools and store it in the local workspace (without installing it)
devtools::build_github_devtools()

# Restart R before continuing
# install the built devtools using the regular `install.packages` command:
install.packages("devtools.zip", repos = NULL)

# Remove the built package archive after installation
unlink("devtools.zip")

#######
# continue with normal installation instructions for any GitHub packages

If all this fails due ot other installation issues on Windows, I recommend pulling up the DESCRIPTION file of the GitHub package you are trying to install and make sure all the mentioned dependencies are installed using install.packages(c("package1", "package2", "package3"), depen=T) (with the needed package names) before proceding to call install_github for the specific GitHub package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment