I'm trying to create a wasm component from a compiled Rust crate which uses wit-bindgen
to export functions.
Though when attempting to create the component, I get the following error:
wasm-tools component new --adapt ./wasi_preview1_component_adapter.wasm -o ./counter.component.new ./target/wasm32-wasi/release/counter.wasm
Error: failed to encode a component from module
Caused by:
module requires an import interface named `wasi_snapshot_preview1`
The wasi_preview1_component_adapter.wasm was compiled from <https://github.com/bytecodealliance/preview2-prototyping/tree/main/crates/wasi-preview1-component-adapter>, and everything is using wasmtime git dependencies (including wasm-tools).
Is this my fault, or is there some new changes in the main branches which are causing this?
This PR seems to be relevant: <https://github.com/bytecodealliance/preview2-prototyping/pull/172>
In the past I've been able to resolve my issues by grabbing wasi_preview1_component_adapter.command.wasm
from the releases page here https://github.com/bytecodealliance/preview2-prototyping/releases/tag/latest and renaming it to wasi_preview1_component_adapter.wasm
Your --adapt
argument is inferring the name wasi_preview1_component_adapter
as the module to adapt, when in fact it should be wasi_snapshot_preview1
. You'll need to pass --adapt foo=bar.wasm
if you don't want to change the filename where foo
is wasi_snapshot_preview1
Last updated: Nov 22 2024 at 16:03 UTC