Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export(install_svn)
export(install_url)
export(install_version)
export(is.package)
export(is_loading)
export(lint)
export(load_all)
export(loaded_packages)
Expand Down Expand Up @@ -90,6 +91,7 @@ importFrom(pkgbuild,find_rtools)
importFrom(pkgbuild,has_devel)
importFrom(pkgbuild,with_debug)
importFrom(pkgload,check_dep_version)
importFrom(pkgload,is_loading)
importFrom(pkgload,parse_deps)
importFrom(pkgload,unload)
importFrom(remotes,dev_package_deps)
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# devtools (development version)

* `is_loading()` is now re-exported from pkgload (#2556).
* `load_all()` now errors if called recursively, i.e. if you accidentally include a `load_all()` call in one of your R source files (#2617).

# devtools 2.4.6

* Functions that use httr now explicitly check that it is installed
Expand Down
11 changes: 11 additions & 0 deletions R/pkgload.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ load_all <- function(
path <- path$path
}

if (is_loading()) {
cli::cli_abort(c(
"Recursive loading detected.",
i = "Did you accidentally include {.fn load_all} in an R source file?"
))
}

save_all()

check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn))
Expand All @@ -29,6 +36,10 @@ load_all <- function(
)
}

#' @importFrom pkgload is_loading
#' @export
pkgload::is_loading

#' @importFrom pkgload unload
#' @export
pkgload::unload
3 changes: 2 additions & 1 deletion man/reexports.Rd

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

4 changes: 3 additions & 1 deletion man/remote-reexports.Rd

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

9 changes: 9 additions & 0 deletions tests/testthat/_snaps/pkgload.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# load_all() errors if called recursively

Code
load_all()
Condition
Error in `load_all()`:
! Recursive loading detected.
i Did you accidentally include `load_all()` in an R source file?

4 changes: 4 additions & 0 deletions tests/testthat/test-pkgload.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test_that("load_all() errors if called recursively", {
local_mocked_bindings(is_loading = function() TRUE)
expect_snapshot(load_all(), error = TRUE)
})
Loading