-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace rlang::is_installed()
with a lightweight solution
#246
Comments
I propose the following internal function: is_installed <- function(package) requireNamespace(package, quietly = TRUE) The only difference is that it returns its value invisibly |
Sounds good. |
Definitely an edge case. I confirmed locally that https://github.com/yihui/xfun/blame/9183dcc56d54f6ab1ef0d33c2eb86dfe8d0346b6/R/packages.R#L87 Though I'm not sure we want to suppress these. Let's say a user runs Thoughts? |
I think that's good enough. No need to consider package startup messages, since this function is currently used only for |
I realized there is another key difference between rlang::is_installed(c("stats", "not-a-valid-package-name"))
## [1] FALSE
head(requireNamespace, 3)
##
## 1 function (package, ..., quietly = FALSE)
## 2 {
## 3 package <- as.character(package)[[1L]]
(requireNamespace(c("stats", "not-a-valid-package-name")))
## [1] TRUE |
I used
rlang::is_installed()
and introduced rlang as a hard dependency in #245 to safeguard code examples, tests, and vignettes and get the package pass thenoSuggests
check.It would be ideal if we can use a lightweight solution here and remove the dependency.
@jdblischak suggested
requireNamespace()
. @yihui also mentionedxfun::loadable()
.The text was updated successfully, but these errors were encountered: