r-wasm / webr

The statistical language R compiled to WebAssembly via Emscripten, for use in web browsers and Node.
https://docs.r-wasm.org/webr/latest/
Other
806 stars 54 forks source link

How to install packages not available on CRAN? #456

Open JosiahParry opened 5 days ago

JosiahParry commented 5 days ago

I'd like to use litedown with webR but running webr::install("litedown") and webr::install("yihui/litedown") both fail saying the package cannot be found.

Any tips here? I suspect the best thing i can do is to build it as part of the {rwasm} build process and mount it.

https://github.com/yihui/litedown

georgestagg commented 5 days ago

Yes, either build the package using {rwasm}, or create a personal r-universe repository (which builds emscripten packages for you automatically using {rwasm}).

Loading packages directly from GitHub using package references such as org/package is not currently supported, because we don't have the necessary toolchain to build the package from source available to us from inside the browser under Wasm.

JosiahParry commented 5 days ago

Understandable. The challenge with using r-universe is that (as far as i can tell) it doesn't give us the library.data and library.js.metadata for something locally.

georgestagg commented 19 hours ago

It should be possible to download the .data and .js.metadata files directly from R Universe. The URLs are not exposed directly in the web UI, but the files are built as part of the Wasm cross-compilation process, and live in the same directory as the .tgz file.

e.g.

https://r-lib.r-universe.dev/bin/emscripten/contrib/4.4/cli_3.6.3.9000.data https://r-lib.r-universe.dev/bin/emscripten/contrib/4.4/cli_3.6.3.9000.js.metadata