Skip to content

Instantly share code, notes, and snippets.

@wch
Last active June 2, 2022 10:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save wch/c942335660dc6c96322f to your computer and use it in GitHub Desktop.
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()
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
Copy link

on my machine, this causes a (C?) warning:

ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.

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?

@wch
Copy link
Author

wch commented Oct 31, 2018

@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.

@schloerke
Copy link

schloerke commented Mar 2, 2021

unlock_environment() has been removed from pkgload. Now it looks like pkgbuild / pak output when calling pkgload::load_all()

@lionel-
Copy link

lionel- commented Jun 2, 2022

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