dart-archive/wasm

dart run wasm:setup fails on linux when referenced as a dependency pointing to git

abner opened this issue · 3 comments

abner commented

I tried to reproduce the example on README on Ubuntu and it failed when i executed dart run wasm:setup.

I got this error:

...
manifest path `/home/abner/dart-wasm-project/.dart_tool/pub/bin/wasm/Cargo.toml` does not exist

I referenced the wasm project in my pubspec.yaml using git reference:

dependencies:
  wasm: 
    git:
      url: https://github.com/dart-lang/wasm.git
      ref: main

I manually copied the files in the wasm repository bin folder (Cargo.toml, finalizers.cc, setup.dart, wasmer.rs) into my .dart_tool/pub/bin/wasm and after it, the command dart run wasm:setup just worked.

Actually, i wanna also to know if dart-lang/wasm is intended to work inside Flutter apps (both mobile, desktop and web)?

maks commented

@abner thanks for raising this issue and including your work around!
I had the same error (on Ubuntu 21.04) and copying across the bin folder worked for me too.
I wonder if copying those files across should be part of setup.dart ?

Actually, i wanna also to know if dart-lang/wasm is intended to work inside Flutter apps (both mobile, desktop and web)?

We plan to support flutter and the web, but currently we only support linux/windows/mac.

The fix for these sorts of errors is usually to add whatever directory pub puts git deps in to the list of directories that setup.dart looks through. Unfortunately, it seems to put git deps in an internal cache that is not relative to any of the other directories that setup.dart knows about, and also puts the git hash in the directory name. For example on my windows machine it ends up in C:\Users\<USER>\AppData\Local\Pub\Cache\git\wasm-8130064aa79227564ac07d561837ded2cefa0d9f.

That wouldn't be a problem, because one of the search paths is wherever the script is. But pub precompiles setup.dart and puts it in the project's .dart_tool folder, so Platform.script points to .dart_tool/pub/bin/wasm, rather than the cloned repo. It seems there's not an easy way for setup.dart to locate that directory.

I think to do this properly I'll need to read the package config file to figure out where wasm ended up. Fortunately there's a package for that :)