webr icon indicating copy to clipboard operation
webr copied to clipboard

Unable to reproduce on MacOS: Mounting filesystem images

Open dusadrian opened this issue 1 year ago • 3 comments

Hi, I followed the instructions from the r-wasm 0.2.0 website. I used a Docker image to build the Wasm R packages, closely following the instructions.

I managed to build several packages and used the add_pkg() command, and finally wanted to test (as per the above page) using a static server.

I used exactly the command suggested:

> httpuv::runStaticServer(
+   dir = ".",
+   port = 9090,
+   browse = FALSE,
+   headers = list("Access-Control-Allow-Origin" =  "*")
+ )
Serving: '.'
View at: http://127.0.0.1:9090
Press Esc or Ctrl + C to stop the server

and upon opening a webR session in the browser, I was unable to mount:

> webr::mount("/my-library", "http://127.0.0.1:9090/vfs/library.data")
Error in webr::mount("/my-library", "http://127.0.0.1:9090/vfs/library.data") : 
  Can't download Emscripten filesystem image metadata.

Then I started the static server in a different R session outside Docker, changing the "dir" argument to the output directory from Docker. Still no luck, neither mounting that image nor installing a package:

> webr::install("cli", repos = "http://127.0.0.1:9090/repo")
Warning: unable to access index for repository http://127.0.0.1:9090/repo/bin/emscripten/contrib/4.4:
  download from 'http://127.0.0.1:9090/repo/bin/emscripten/contrib/4.4/PACKAGES' failed
Warning message:
In webr::install("cli", repos = "http://127.0.0.1:9090/repo") :
  Requested package cli not found in webR binary repo.

This should work, but I just cannot get it done. I am on MacOS if that makes a difference, although I imagine it shouldn't.

dusadrian avatar Jan 21 '25 18:01 dusadrian

I just tried on a Windows virtual machine, and it works there. So the problem must be related on MacOS, in which case I am unclear as to what to do next.

dusadrian avatar Jan 22 '25 05:01 dusadrian

Thanks for reporting back the working behaviour on Windows.

I think this is related to https://github.com/r-wasm/webr/issues/475, where volume mounting is not working correctly under macOS.

There is a workaround in that thread that might be useful, (involving copying the output directories from the docker image to the environment outside Docker before starting the web server), but I have not tracked down the underlying issue yet.

georgestagg avatar Jan 22 '25 08:01 georgestagg

Thanks for the follow-up. Happy to report this is a MacOS issue only for Safari. It works on Chrome, which I failed to test prior to submitting this issue.

It does not seem related to #475, as either way (directly saving into the /output or copying from Docker) work alright in Chrome. It is Safari that behaves differently, from some reason.

In fact, the whole exercise was for me to make sure I can mount an R library into a Node.js application. Now that I passed over this step, I have a different problem for which I will submit a new issue. Not sure if I should close the issue or not, so I leave it up to you. To me it is solved.

dusadrian avatar Jan 22 '25 18:01 dusadrian