Last active
June 2, 2022 10:39
-
-
Save wch/c942335660dc6c96322f to your computer and use it in GitHub Desktop.
Shim system.file for htmlwidgets so that a dependent package can be used with devtools::load_all()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shim_system_file <- function(package) { | |
imports <- parent.env(asNamespace(package)) | |
pkgload:::unlock_environment(imports) | |
imports$system.file <- pkgload:::shim_system.file | |
} | |
shim_system_file("htmlwidgets") | |
shim_system_file("htmltools") | |
# After the code above has been run, you can load an in-development package | |
# that uses htmlwidgets (like dygraphs or leaflet). After being loaded this way, | |
# When the JS or CSS resources of the package are edited, they'll immediately | |
# be available, without having to build and install the package. | |
load_all() | |
@maxheld83 I've been seeing this whenever I compile any code for R packages on my system. I think it's just an issue with XCode and macOS.
That said, I just realized that it's no longer necessary to compile the code in each R session, because of the pkgload:::unlock_environment()
function. I've updated the gist to use this.
unlock_environment()
has been removed from pkgload
. Now it looks like pkgbuild
/ pak
output when calling pkgload::load_all()
There is still rlang::env_unlock()
but it's unsure that we can keep this function in rlang in the long term.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
on my machine, this causes a (C?) warning:
I'm just ignoring this, but it seems impossible to suppress this "warning", because it come right from C through
stdout
.Not knowing any C, I can't quiet it down. Any chance you might?