bytecodealliance / cargo-wasi

A lightweight Cargo subcommand to build Rust code for the `wasm32-wasi` target
https://bytecodealliance.github.io/cargo-wasi/
Apache License 2.0
444 stars 29 forks source link

`cargo wasi build` fails to run `wasm-bindgen` with `No such file or directory (os error 2)` #142

Open landonxjames opened 1 year ago

landonxjames commented 1 year ago

I have a project encountering an error when trying running wasm-bindgento build. I can get Hello World building just fine with cargo wasi, so I suspect something about this particular project is causing the failure. Here is a copy of the project. And I am on cargo/rustc 1.70.0 and cargo wasi 0.1.28 on an M1 Macbook

$ cargo --version           
cargo 1.70.0 (ec8a8a0ca 2023-04-25)
$ rustc --version
rustc 1.70.0 (90c541806 2023-05-31)
$ cargo wasi --version                                      
cargo-wasi 0.1.28

Here is a (slightly truncated) full output of the command:

$ cargo wasi build --verbose
     Running "cargo" "build" "--target" "wasm32-wasi" "--message-format" "json-render-diagnostics" "--verbose"
       ...
       bunch of packages compiling
       ...
    Finished dev [unoptimized + debuginfo] target(s) in 1.15s
     Running WASM_INTERFACE_TYPES="1" "/Users/lnj/Library/Caches/cargo-wasi/0.1.28/wasm-bindgen/0.2.87/wasm-bindgen" "/Volumes/workplace/wasitest/target/wasm32-wasi/debug/wasitest.rustc.wasm" "--keep-debug" "--out-dir" "/Volumes/workplace/wasitest/target/wasm32-wasi/debug/.tmpUzkDwI" "--out-name" "foo"
error: failed to process wasm at `/Volumes/workplace/wasitest/target/wasm32-wasi/debug/wasitest.rustc.wasm`

Caused by:
    No such file or directory (os error 2)

I can manually run wasm-bindgen successfully using the same version that cargo wasi uses:

$ wasm-bindgen --version          
wasm-bindgen 0.2.87
$ WASM_INTERFACE_TYPES="1" wasm-bindgen ./target/wasm32-wasi/debug/wasitest.rustc.wasm --out-dir ./wmbgout --keep-debug

The output WASM file fails at runtime from what appears to be a AWS Rust SDK bug so probably unrelated to this bug.