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
848 stars 67 forks source link

Installation from r-universe emits an error about `PACKAGES.rds` #435

Open helgasoft opened 3 months ago

helgasoft commented 3 months ago

Appreciation and gratitude for your work, WebR is a gamechanger ! 🏆 I have two questions related to installation.

Wondering how often those 20K binary repo packages are re-compiled to WebAssembly. Is there some trigger by package, or a general update schedule for all packages (monthly, etc.), or is it a non-scheduled batch job ?

There is a footnote in the docs about an alternative repo called r-universe. Looks good indeed and they recompile really fast the latest package version when published. But trying to install from them I got and reported an error. Here is the code:

var webR;
import('https://webr.r-wasm.org/latest/webr.mjs').then(async ({ WebR }) => {
  webR = new WebR();
  await webR.init();
  // ok, but gets older version from repo.r-wasm.org :
  // await webR.installPackages(["echarty"])  

  // trying to get the latest version
  await webR.installPackages(["echarty"], {repos:'https://helgasoft.r-universe.dev'});  
ERROR 404:
https://helgasoft.r-universe.dev/bin/emscripten/contrib/4.4/PACKAGES.rds
Unsupported PACKAGES format: rds

To summarize the issue - repo.r-wasm.org works fine, but packages are not updated often, r-universe.dev has quick updates, but generates some installation error.

georgestagg commented 3 months ago

Wondering how often those 20K binary repo packages are re-compiled to WebAssembly.

It's currently a non-scheduled batch job. Updates follow CRAN versions of packages but on a much slower release frequency. I can also update individual packages on request.


AFAICT it doesn't look like r-universe generates a PACKAGES.rds file, leading to the 404 error. However, R has fallback options, PACKAGES.gz and PACKAGES, which do exist. So, despite the error message, R should have continued on and loaded the package list from one of the fallback options.

For me, at least in a web browser, when I run

await webR.installPackages(["echarty"], {repos:'https://helgasoft.r-universe.dev'});
await webR.installPackages(["dplyr", "htmlwidgets", "data.tree"]);

The error is generated, but R continues to download using the fallback option and once complete I can successfully run

library(echarty)

I will try to think if there is some better way to raise and report the network error in this context.

helgasoft commented 3 months ago

despite the error message, R should have continued on and loaded the package list from one of the fallback options.

Yes, correct.     Just FYI some performance data, o3 are (dplyr, htmlwidgets, data.tree)

loading elapsed ms
echarty only from r-wasm (o3 auto-loaded as dependencies) 7,354
echarty from r-universe, o3 from r-wasm (your example) 7,976
echarty and o3 (one-by-one), all from r-universe 12,784

So loading from r-wasm is almost twice as fast as r-universe (at least from my PC and location). BTW, thanks for updating echarty to the latest version 🤙