r-wasm / rwasm

Build R packages for WebAssembly and create a CRAN-like repo for distribution.
https://r-wasm.github.io/rwasm/
Other
54 stars 4 forks source link

make_vfs_repo() not able to find `/repo/bin/emscripten/contrib` #26

Closed JosiahParry closed 5 months ago

JosiahParry commented 5 months ago

I was able to create a library.data file initially. I then deleted it after adding a package to the repo so I could update the library.data file. Now, however, make_vfs_repo() will not recreate the file or let alone the "/vfs" folder

As shown below, the repo has the structure created by add_pkg() but make_vfs_repo()` does not recognize it. Then, after the first run, it continues to silently fail.

image
JosiahParry commented 5 months ago

Woke up and RTFM-ed with a fresh set of eyes. https://r-wasm.github.io/rwasm/articles/mount-fs-image.html

georgestagg commented 5 months ago

I think there are several things going wrong here.


make_vfs_repo() does not create a vfs directory or library.data, it iterates over packages in a repository and creates filesystem images for each package, e.g.

> rwasm::make_vfs_repo()
Packaging: R6_2.5.1.data
Packaging: cli_3.6.2.data
[...]

Note that this is no longer a required step, add_pkg() performs this step automatically. The make_vfs_repo() function will probably be un-exported in a future version of rwasm.


I think you are thinking of make_vfs_library(). This function takes a repository and builds an R package library from the packages within - writing the resulting filesystem image to ./vfs/library.data by default.

> rwasm::make_vfs_library()
Packaging: library.data

Note that this process is only really required if you want to distribute your R package library as a single filesystem image. It is not required if you are only interested in loading custom R packages from a statically hosted webR repository on e.g. GitHub Pages.


Next, I can see error messages when rwasm is loaded:

1: In find_webr() : Unable to find webr root directory.
2: In find_emscripten() : Unable to find Emscripten root directory.

This means that rwasm cannot find a webR developer installation or an Emscripten installation on your machine. The easiest way to fix this is probably to use the webR developer Docker image, as described in the Setting up the WebAssembly toolchain section of the Getting started guide.

Without access to a webR developer installation or Emscripten, rwasm will be unable to build or package R packages. It's possible that is is contributing to the issues. I agree that the messaging and error output here should be clearer and better explain what is wrong.


Finally, I see you are trying to build the tidyverse. Once you are able to build packages, note that you'll need to additionally build any package dependencies. You can tell rwasm to do this with e.g.

rwasm::add_pkg("tidyverse", dependencies = NA)

Note that tidyverse is a large package with many dependencies, and some of them cannot work in any case such as the curl package. I would recommend starting with a simpler subset of the tidyverse packages, such as dplyr or vctrs, until you are more comfortable building Wasm R package binaries.


I am sorry you are having trouble here. Cross-compiling packages for Wasm is tricky, and writing documentation for the process is trickier still. Hopefully we can improve all of this before releasing a stable v0.1.0 or v1.0.0.

georgestagg commented 5 months ago

Woke up and RTFM-ed with a fresh set of eyes. https://r-wasm.github.io/rwasm/articles/mount-fs-image.html

Whoops, I see you closed while I was writing my long reply 😛. Glad you were able to figure it out!

JosiahParry commented 5 months ago

I think unexporting make_vfs_repo() would help, actually! I think the documentation between the two was the source of my confusion