HI
I was trying to run one of the examples which is wasi, main.rs file.
these are the two commands I executed.
cmake examples/
cargo run --example wasi
but I Gott he following error
error:** failed to run custom build command for test-programs-artifacts v0.0.0 (/Users/celinesantosh/Desktop/sem_5/wasmtime/crates/test-programs/artifacts)
Caused by:
process didn't exit successfully: /Users/celinesantosh/Desktop/sem_5/wasmtime/target/debug/build/test-programs-artifacts-22b912d9b572dd6f/build-script-build
(exit status: 101)
--- stdout
cargo:rerun-if-changed=../../wasi-preview1-component-adapter
--- stderr
running: env -u CARGO_ENCODED_RUSTFLAGS CARGO_TARGET_DIR="/Users/celinesantosh/Desktop/sem_5/wasmtime/target/debug/build/test-programs-artifacts-2e8e593f7698d1fd/out" RUSTFLAGS="" "cargo" "build" "--release" "--package=wasi-preview1-component-adapter" "--target=wasm32-unknown-unknown"
Compiling indexmap v2.2.6
Compiling serde_json v1.0.107
Compiling serde_derive v1.0.188
Compiling memchr v2.5.0
Compiling prettyplease v0.2.20
Compiling byte-array-literals v24.0.0 (/Users/celinesantosh/Desktop/sem_5/wasmtime/crates/wasi-preview1-component-adapter/byte-array-literals)
Compiling wit-bindgen-rust-macro v0.27.0
Compiling object v0.36.0
Compiling wasi v0.11.0+wasi-snapshot-preview1
error[E0463]: can't find crate for core
|
= note: the wasm32-unknown-unknown
target may not be installed
= help: consider downloading the target with rustup target add wasm32-unknown-unknown
= help: consider building the standard library from source with cargo build -Zbuild-std
For more information about this error, try rustc --explain E0463
.
error: could not compile wasi
(lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
thread 'main' panicked at crates/test-programs/artifacts/build.rs:138:5:
assertion failed: status.success()
note: run with RUST_BACKTRACE=1
environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...**
The solution is buried a bit in the output, but it's there:
= note: the
wasm32-unknown-unknown
target may not be installed= help: consider downloading the target with
rustup target add wasm32-unknown-unknown
If you run that rustup
command, that should fix the issue.
that fixed it but still I am encountering issues.
MacBook-Air-2 wasmtime % cargo run --example wasi-async
Compiling wasmtime-cli v24.0.0 (/Users/celinesantosh/Desktop/sem_5/wasmtime)
Finished dev
profile [unoptimized + debuginfo] target(s) in 3.81s
Running target/debug/examples/wasi-async
Error: failed to read input file: target/wasm32-wasi/debug/wasi.wasm
Caused by:
No such file or directory (os error 2)
I'm going to ask the obvious question: is there such a file or directory?
I don't think cargo run
works for wasm32-wasi binaries. You'll need to use e.g. 'wasmtime run' to run the output, or else consider using https://github.com/bytecodealliance/cargo-wasi
Hi
thanks a lot for the quick replies.
For the wasi example , in the main.rs file I changed the path to /target/wasm32-wasi/release/wasi.wasm.
I found that the wasi.wasm was being generated at this location. So I changed the main.rs file and now it prints the output.
Yay! !
Last updated: Dec 23 2024 at 12:05 UTC