Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run wasmtime component (Error: No such file or directory (os error 2)) #10291

Open
tpmccallum opened this issue Feb 25, 2025 · 6 comments

Comments

@tpmccallum
Copy link

I am compiling using the following command:

$ cargo component build --target wasm32-wasip2
  Generating bindings for compress (src/bindings.rs)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.07s

But when I use wasmtime I get an error:

$ wasmtime component run --env PATH=$PATH --dir . --invoke compress target/wasm32-wasip2/debug/compress.wasm
Error: No such file or directory (os error 2)

I put the source code and config in a repo so you can see everything. Super stumped on this one, would appreciate some assistance.

https://github.com/tpmccallum/testing_components/blob/main/README.md

@tpmccallum
Copy link
Author

Here are some details of my system/setup that might help with the diagnosis:

$ rustc --version
rustc 1.87.0-nightly (f8a913b13 2025-02-23)
$ cargo component --version
cargo-component-component 0.20.0
$ wasmtime --version
wasmtime 30.0.1
$ uname -a
Darwin Kernel Version 24.3.0: X86_64

The target/wasm32-wasip2 file exists.
I tried updating cargo-component, forcing wasip2 in config but output in the CLI still says wasip1.
Is wasmtime 30.0.1 mishandling wasip2 components?
The auto-generated bindings.rs mention wit-bindgen:0.36.0 and I am not sure if the bindings being generated are correct.
wit-bindgen:0.36.0

@bjorn3
Copy link
Contributor

bjorn3 commented Feb 25, 2025

Does the target/wasm32-wasip2/debug/compress.wasm file exist?

@tpmccallum
Copy link
Author

Yes, the target/wasm32-wasip2/debug/compress.wasm does exist.

@alexcrichton
Copy link
Member

Thanks for the report! (and 👋)

I think the problem here is that wasmtime component run isn't a subcommand of the wasmtime executable. Coupled with Wasmtime's bad error message (which is improved at #10292 now) I think that led to the confusion here.

When removing component I then get:

$ wasmtime run --env PATH=$PATH --dir . --invoke compress target/wasm32-wasip2/debug/compress.wasm
Error: failed to run main module `target/wasm32-wasip2/debug/compress.wasm`

Caused by:
    using `--invoke` with components is not supported

which is expected in that --invoke isn't supported for components just yet.

@pchickey
Copy link
Contributor

pchickey commented Feb 25, 2025

expected in that --invoke isn't supported for components just yet.

Its not that far off but I haven't had the time or energy to get it over the finish line. If someone else wants to pick it up, ping me on the PR or zulip #10054

@tpmccallum
Copy link
Author

Thanks for the reply @bjorn3, @pchickey.
Thanks, @alexcrichton (and 👋 back).

This is super helpful and appreciated.

wasip1/wasip2
Some of the confusion (not wasmtime related specifically) was because I thought the cargo component command supported wasip2. I have since learned that it does not. Based on the output I was getting when generating the bindings I thought that something was off with my config or toolchain and I chased my own tail for quite a while.

Error: No such file or directory (os error 2)
Thanks for the improved error message, that makes sense now.

Invoke Functionality
I went ahead and fetched @pchickey's PR to test the --invoke out locally. Here's the results:

cd /Users/tpmccallum
git clone https://github.com/bytecodealliance/wasmtime.git
cd wasmtime
git checkout main
git pull origin main
git checkout pch/invoke_wave
git merge main
cargo clean
cargo build --release

I then tried to run the component and got the following result (hopefully useful feedback for the continuation of the work on #10054):

tpmccallum@192-168-1-17 compress % /Users/tpmccallum/wasmtime/target/release/wasmtime run --invoke compress target/wasm32-wasip1/debug/compress.wasm

Error: failed to run main module `target/wasm32-wasip1/debug/compress.wasm`

Caused by:
    0: parsing invoke "compress"
    1: unexpected end of input at 8..8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants