Skip to content

Commit

Permalink
Change default value of R_REMOTES_NO_ERRORS_FROM_WARNINGS
Browse files Browse the repository at this point in the history
This will now no longer cause installs to fail if there are warnings
during installation.

There are unfortunately too many warnings emitted from
`install.packages()` that are _not_ due to install failures, so the
previous default was too aggressive.

Fixes #403
  • Loading branch information
jimhester committed Aug 6, 2020
1 parent d7fe461 commit 5a546ad
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 36 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# remotes (development version)

* `install_*()` functions will no longer fail by default if there warnings from `install.packages()`. Concretely the default value of `R_REMOTES_NO_ERRORS_FROM_WARNINGS` has changed to `true` from the previous value of `false`. (#403)

# remotes 2.2.0

## New functions and features
Expand Down
4 changes: 1 addition & 3 deletions R/install.R
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,7 @@ install_deps <- function(pkgdir = ".", dependencies = NA,

should_error_for_warnings <- function() {

force_suggests <- Sys.getenv("_R_CHECK_FORCE_SUGGESTS_", "true")

no_errors <- Sys.getenv("R_REMOTES_NO_ERRORS_FROM_WARNINGS", !config_val_to_logical(force_suggests))
no_errors <- Sys.getenv("R_REMOTES_NO_ERRORS_FROM_WARNINGS", "true")

!config_val_to_logical(no_errors)
}
13 changes: 3 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,9 @@ It also uses some remotes specific options:
mode and avoid loading its optional dependencies (curl, git2 and pkgbuild
currently. See "Standalone mode" above.

* Setting `R_REMOTES_NO_ERRORS_FROM_WARNINGS="true"` avoids stopping the
installation for warning messages. Warnings usually mean installation
errors, so by default remotes stops for a warning. However, sometimes
other warnings might happen, that could be ignored by setting this
environment variable.

* Setting `_R_CHECK_FORCE_SUGGESTS_="false"` while
`R_REMOTES_NO_ERRORS_FROM_WARNINGS` is unset will also avoid stopping the
installation for error messages. This is done because a warning is generated
during installation when not all Suggested packages are not available.
* Setting `R_REMOTES_NO_ERRORS_FROM_WARNINGS="false"` will cause warning
messages during calls to `install.packages()` to become errors. Often warning
messages are caused by dependencies failing to install.

## License

Expand Down
4 changes: 1 addition & 3 deletions inst/install-github.R

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions install-github.R

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 8 additions & 17 deletions tests/testthat/test-install.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,35 +104,26 @@ test_that("safe_build_package calls pkgbuild with appropriate arguments", {

test_that("should_error_for_warnings works", {

# If both unset, should error -> TRUE
withr::with_envvar(c("R_REMOTES_NO_ERRORS_FROM_WARNINGS" = NA, "_R_CHECK_FORCE_SUGGESTS_" = NA),
expect_true(should_error_for_warnings())
)

# If no errors true, should error -> FALSE
withr::with_envvar(c("R_REMOTES_NO_ERRORS_FROM_WARNINGS" = "true", "_R_CHECK_FORCE_SUGGESTS_" = NA),
expect_false(should_error_for_warnings())
)
withr::with_envvar(c("R_REMOTES_NO_ERRORS_FROM_WARNINGS" = "1", "_R_CHECK_FORCE_SUGGESTS_" = NA),
# If unset, should error -> false
withr::with_envvar(c("R_REMOTES_NO_ERRORS_FROM_WARNINGS" = NA),
expect_false(should_error_for_warnings())
)

# If no errors unset, and force_suggests false, should error -> FALSE
withr::with_envvar(c("R_REMOTES_NO_ERRORS_FROM_WARNINGS" = NA, "_R_CHECK_FORCE_SUGGESTS_" = "false"),
# If set to true, should error -> false
withr::with_envvar(c("R_REMOTES_NO_ERRORS_FROM_WARNINGS" = "true"),
expect_false(should_error_for_warnings())
)
withr::with_envvar(c("R_REMOTES_NO_ERRORS_FROM_WARNINGS" = NA, "_R_CHECK_FORCE_SUGGESTS_" = "0"),
withr::with_envvar(c("R_REMOTES_NO_ERRORS_FROM_WARNINGS" = "1"),
expect_false(should_error_for_warnings())
)

# If no errors unset, and force_suggests true, should error -> TRUE
withr::with_envvar(c("R_REMOTES_NO_ERRORS_FROM_WARNINGS" = NA, "_R_CHECK_FORCE_SUGGESTS_" = "true"),
# If set to true, should error -> true
withr::with_envvar(c("R_REMOTES_NO_ERRORS_FROM_WARNINGS" = "false"),
expect_true(should_error_for_warnings())
)
withr::with_envvar(c("R_REMOTES_NO_ERRORS_FROM_WARNINGS" = NA, "_R_CHECK_FORCE_SUGGESTS_" = "1"),
withr::with_envvar(c("R_REMOTES_NO_ERRORS_FROM_WARNINGS" = "0"),
expect_true(should_error_for_warnings())
)

})

test_that("normalize_build_opts works", {
Expand Down

0 comments on commit 5a546ad

Please sign in to comment.