Skip to content

Commit

Permalink
Prompt to install build tools when needed.
Browse files Browse the repository at this point in the history
Closes #488
  • Loading branch information
hadley committed Jun 30, 2014
1 parent 68d37d0 commit 44c2472
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Expand Up @@ -33,6 +33,10 @@

## Other minor improvements and bug fixes

* If you're using Rstudio, and you you're trying to build a binary package
without the necessary build tools, Rstudio will prompt to download and
install the right thing. (#488)

* devtools no longer runs commands with `LC_ALL=C` - this no longer seems
to be necessary (#507).

Expand Down
2 changes: 2 additions & 0 deletions R/build.r
Expand Up @@ -28,6 +28,8 @@
build <- function(pkg = ".", path = NULL, binary = FALSE, vignettes = TRUE,
args = NULL, quiet = FALSE) {
pkg <- as.package(pkg)
check_build_tools(pkg)

if (is.null(path)) {
path <- dirname(pkg$path)
}
Expand Down
13 changes: 13 additions & 0 deletions R/has-devel.r
Expand Up @@ -23,3 +23,16 @@ has_devel <- function() {
stopifnot(.C(dll$foo, 0L)[[1]] == 1L)
TRUE
}

check_build_tools <- function(pkg = ".") {
pkg <- as.package(pkg)
if (!file.exists(pkg$path, "src")) return(TRUE)

This comment has been minimized.

Copy link
@krlmlr

krlmlr Jul 2, 2014

Member

Gives a warning (output with options(warn=2):

Error in if (!file.exists(pkg$path, "src")) return(TRUE) : 
  (converted from warning) the condition has length > 1 and only the first element will be used

Perhaps file.exists(file.path(...?


check <- getOption("buildtools.check", NULL)
if (!is.null(check)) {
check("Installing R package from source")
} else {
# Outside of Rstudio and don't have good heuristic
TRUE
}
}
1 change: 1 addition & 0 deletions R/install.r
Expand Up @@ -53,6 +53,7 @@ install <- function(pkg = ".", reload = TRUE, quick = FALSE, local = TRUE,
threads = getOption("Ncpus", 1)) {

pkg <- as.package(pkg)
check_build_tools(pkg)

if (!quiet) message("Installing ", pkg$package)
install_deps(pkg, dependencies = dependencies, threads = threads)
Expand Down

0 comments on commit 44c2472

Please sign in to comment.