Skip to content

Commit

Permalink
Check for sealed namespace in is_installed()
Browse files Browse the repository at this point in the history
Closes #1378
  • Loading branch information
lionel- committed May 24, 2022
1 parent 2b472ff commit d2f1a7b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion R/session.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ detect_installed <- function(info) {
}

flatten_lgl(pmap(info, function(pkg, cmp, ver) {
if (requireNamespace(pkg, quietly = TRUE)) {
# Check for sealed namespaces to protect against `is_installed()`
# being called from user hooks of `pkg` (#1378)
is_fully_loaded <-
requireNamespace(pkg, quietly = TRUE) &&
env_is_locked(ns_env(pkg))

if (is_fully_loaded) {
is_na(ver) || exec(cmp, utils::packageVersion(pkg), ver)
} else {
FALSE
Expand Down

0 comments on commit d2f1a7b

Please sign in to comment.