I want to use wasmtime design a plugin system. when I load wasm component I got this error: import wasi:io/error@0.2.0-rc-2023-11-10 has the wrong type
I just defined a wit file then use wit-bindgen to generate wasm binary file and use wasm-tools transfer it to a component with a paramter "--adapt wasi_snapshot_preview1.wasm"
My wit like this:
wit package downow:downloader;
interface plugin {
enum error {
invalid-name,
}
greet: func(msg: string) -> result<string, error>;
}
world downloader {
export plugin;
}
wit-bindgen-cli 0.15.0
wasm-tools 1.0.53
Without the full error context this is likely due to the fact that you'll need to configure WASI in Wasmtime to be available and it may not be configured quite right. Given that version number in the interface you'll also want to make sure you're using Wasmtime 15.
If I recall that error correctly you just need to add wasmtime_wasi::preview2::bindings::io::error::add_to_linker(&mut linker, |x| x)?;
(deleted)
Oh that’s my bad
Does command not include that?
That interface is new in a pretty recent refactoring, we moved existing stuff to a new interface
I found the reason.Cause I use cargo build --target wasm32-wasi
to build the module. now I use --target wasm32-unknown-unknown
to build. Bug I have a question. why I use the first one can not load and got this error? And what cases need to use wasm32-wasi
paramter ?
Last updated: Nov 22 2024 at 16:03 UTC