-
Notifications
You must be signed in to change notification settings - Fork 72
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
Using Node.js, how to install R packages from Emscripten’s filesystem image with a small CRAN-like repo #495
Comments
Hi, Your code to mount the filesystem image is good. However, when mounting a filesystem image you can skip the entire step of using an R package repository and installing packages. Instead, you can just mount a filesystem image that contains the files of already installed R packages, and use How are you currently generating your fileystem image? Are you using automation such as GitHub Actions, or manually? If manually, are you using the Once you have generated that library image, it should consist of two files named something like
Once that's done, you can continue with something like: await webR.evalR(`.libPaths(c(.libPaths(), "/my-library"))`) and then finally await webR.evalR(`library(maven)`) |
Tes I'm doing it manually. |
Hi, it worked 😄 Then I started testing, and got an error message:
After adding 'rlang' to the vfs library and retrying, I got another error about another missing package.
|
Hello, I couldn't find the answers in the documentation, can you please clarify: When I'm done using webR in a Node.js context, and want to properly dispose of it, is there anything else needed / recommended other than:
E.g. do I need to unmount filesystem images and/or directories previously mounted ? Thank you |
Hi, Nothing else is recommended other than The only requirement I am aware of is awaiting the
A convenience function to do this is not currently exposed to the main webR JavaScript thread. I don't think it's strictly necessary, but if you are willing to experiment you could execute JS code on the worker thread using # Mount some filesystems
webr::mount(mountpoint = "/data", source = "[...]")
webr::mount(mountpoint = "/data2", source = "[...]")
# Find current mounts
mounts <- webr::eval_js("Module.FS.root.mount.mounts.map((m) => m.mountpoint)")
mounts
# [1] "/proc/self/fd" "/data" "/data2"
# Drop the first element, Emscripten handles "/proc/self/fd"
> mounts <- mounts[-1]
# [1] "/data" "/data2"
# unmount the others
lapply(mounts, function(m) webr::unmount(m)) This will require the latest version of webR (required to return the list of strings back to R). Further documentation about the Emscripten |
Hello,
I've been able to create a Emscripten’s filesystem image with a small CRAN-like repo with a few R packages (haven and jsonlite) and mount from the local filesystem using node.js, as shown below.
My goal is to import data using maven and return it as JSON to javascript.
But then I'm confused how to install / access R packages from that mounted filesystem ?
I can see the
src
andbin
subfolders in the mounted filesystem image:I tried the following but it failed:
and
Thanks a lot for your help!
The text was updated successfully, but these errors were encountered: