Skip to content
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

Absolute Path Dependencies #467

Open
markegge opened this issue Oct 6, 2017 · 0 comments
Open

Absolute Path Dependencies #467

markegge opened this issue Oct 6, 2017 · 0 comments

Comments

@markegge
Copy link

markegge commented Oct 6, 2017

In my use case, I'm displaying a Leaflet Map R Object created in one environment in a Shiny dashboard in a different environment. There is considerably processing that happens to create the Leaflet Map R Object, which is not suitable for the dashboard deployment environment.

In plugin-providers.R and other files the absolute paths of the dependencies (e.g. /Library/Frameworks/R.framework/Versions/3.4/Resources/library/leaflet/htmlwidgets/lib/leaflet-providers) are written into the object:

leafletProviderDependencies <- function() {
  list(
    htmltools::htmlDependency(
      "leaflet-providers",
      "1.0.27",
      system.file("htmlwidgets/lib/leaflet-providers", package = "leaflet"),
      script = "leaflet-providers.js"
    ),
    ....
}

Trying to load a map object created on one platform on different platform produces errors like the following:

Error in normalizePath: path[1]="/Library/Frameworks/R.framework/Versions/3.4/Resources/library/leaflet/htmlwidgets/lib/leaflet-providers": No such file or directory
Stack trace (innermost first):
    83: h
    82: .handleSimpleError
    81: normalizePath
    80: addResourcePath
    79: FUN
    78: lapply
    77: origRenderFunc
    76: output$scores_map
    75: ..stacktraceon..
...
     1: runApp

To prevent this error, store the relative path of the dependency rather than the absolute path. Currently, my work-around when loading a saved map object looks like (this is not a good solution, but works for my needs):

data("my_map.Rda") # reads in my_map, a stored Leaflet Map Object
# fix an isssue where these dependencies are hard coded in the stored R objects
my_map$dependencies[[1]]$src$file <- normalizePath(paste0(.libPaths()[1], "/leaflet/htmlwidgets/lib/leaflet-providers"))
my_map$dependencies[[2]]$src$file <- normalizePath(paste0(.libPaths()[1], "/leaflet/htmlwidgets/plugins/leaflet-providers-plugin"))

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant