Closed stobor827 closed 3 weeks ago
WebR has been configured to download R packages as VFS MEMFS
images by default. With this, VFS images are mounted in place rather than written to the NODEFS
mounted filesystem as individual files.
So, rather than using install.packages()
, tell webR to install R packages without mounting a MEMFS
VFS image using the mount
argument of webr::install()
. With that, the package contents should be written to the NODEFS
mount as expected:
await globalThis.webR.FS.mkdir('/library')
await globalThis.webR.FS.mount('NODEFS', { root: './extra' }, '/library');
await globalThis.webR.evalR(".libPaths(\"/library\")");
await globalThis.webR.evalR("webr::install(\"cli\", mount = FALSE)");
$ node packages.mjs
webr init
Downloading webR package: cli
^C
$ ls extra
cli
$ ls extra/cli
DESCRIPTION INDEX LICENSE [...]
This worked great, thank you.
I am attempting what was discussed in #260 for NodeJS but do not see how to download the packages in order to build them into a library. It is also hinted at in step one of this reply for a in-browser implementation: https://github.com/r-wasm/webr/issues/428#issuecomment-2134723022
I was hoping to be able to mount a NODEFS library, setup my .libpaths() to use it, then just installPackages() into it, but this crashes. Is there a simple method I am missing? I made sure that the "./extra" dir was writeable, not sure if there is other setup I need to perform.