Stream: general

Topic: Replacing `cargo-wasi` with `cargo-component`


view this post on Zulip Aryeh Hillman (Sep 10 2025 at 20:33):

Hey there -- I am curious about how to replace cargo wasi run with cargo-component or something else?

view this post on Zulip Alex Crichton (Sep 10 2025 at 20:36):

You can use cargo run --target wasm32-wasip2 for this and also setting CARGO_TARGET_WASM32_WASIP2_RUNNER=wasmtime

view this post on Zulip Aryeh Hillman (Sep 10 2025 at 20:37):

This is super helpful! Can CARGO_TARGET_WASM32_WASIP2_RUNNER=wasmtime be set as a default in Cargo.toml/ .cargo/config.toml?

view this post on Zulip Alex Crichton (Sep 10 2025 at 20:38):

yeah there it'd be:

[target.wasm32-wasip2]
runner = 'wasmtime'

view this post on Zulip Alex Crichton (Sep 10 2025 at 20:38):

er, that's in .cargo/config.toml, not Cargo.toml

view this post on Zulip Aryeh Hillman (Sep 10 2025 at 20:42):

tysm!

view this post on Zulip Celarye (Sep 25 2025 at 13:35):

Is there an explanation of what CARGO_TARGET_WASM32_WASIP2_RUNNER=wasmtimechanges exactly as I have been building my components without it and have not noticed any issues?

view this post on Zulip bjorn3 (Sep 25 2025 at 13:53):

The runner is an executable that will be used by cargo when doing cargo run, cargo test or cargo bench to run the compiled executable. Without setting the runner to wasmtime these things would fail as your OS doesn't know how to execute wasm.

view this post on Zulip Celarye (Sep 26 2025 at 09:25):

That makes sense, all I was doing was building anyways.


Last updated: Dec 06 2025 at 05:03 UTC