-
Notifications
You must be signed in to change notification settings - Fork 75
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
Support IDBFS
for persisting installed packages
#442
Comments
In a543b3e I have added Please read the additional IDBFS documentation carefully; it outlines how to use the
The webR documentation goes into more detail and links to the Emscripten FS API documentation. Please let me know if anything needs to be clarified in the text. For your particular use case the scheme would look something like this, in JavaScript: // Create a `/data` directory for IDBFS and mount it
await webR.FS.mkdir('/data');
await webR.FS.mount('IDBFS', {}, '/data');
// Populate the `/data` directory from IndexedDB. The first time, this will be empty
await webR.FS.syncfs(true);
// Install R packages to `/data/library`
// NOTE: The `mount = FALSE` argument is very important here
await webR.evalRVoid("webr::install('dplyr', lib = '/data/library', mount = FALSE)")
// Synchronise to write the packages' file data to IndexedDB
await webR.FS.syncfs(false); Then, after a web browser refresh: // Create a `/data` directory for IDBFS and mount it
await webR.FS.mkdir('/data');
await webR.FS.mount('IDBFS', {}, '/data');
// Populate the `/data` directory from IndexedDB.
await webR.FS.syncfs(true);
// The previously persisted packages should now be available under `/data/library` Once the VFS is synchronised as above, we have in R: > list.files("/data")
[1] "library"
> .libPaths(c("/data/library", .libPaths()))
> library(dplyr)
Attaching package: ‘dplyr’
The following objects are masked from ‘package:stats’:
filter, lag
The following objects are masked from ‘package:base’:
intersect, setdiff, setequal, union Finally, I don't know what your Rust bindings look like but do be aware that I'm not sure what this will look like in Rust, but in JavaScript this means either |
I am working through how to persist installed R packages in a manner that can be supported outside of the Node runtime.
The two options provided are WORKERFS and NODEFS. In my case, as I am using WebR via Rust & WASM, I cannot use the NODEFS.
The issue with WORKERFS is that the when a page is reloaded, the workers die and the persistence with it.
Alternatives would be to use the browser Filesystem API or IndexedDB. At present, Emscripten supports only IndexedDB via IDBFS.
Being able to support one of these would (I believe) allow me to persist R packages across page reloads.
The text was updated successfully, but these errors were encountered: