Stream: general

Topic: An error with load wasm component


view this post on Zulip Banna Jack (Dec 01 2023 at 08:20):

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

view this post on Zulip Alex Crichton (Dec 01 2023 at 15:04):

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.

view this post on Zulip Christof Petig (Dec 02 2023 at 07:20):

If I recall that error correctly you just need to add wasmtime_wasi::preview2::bindings::io::error::add_to_linker(&mut linker, |x| x)?;

view this post on Zulip Pat Hickey (Dec 03 2023 at 04:21):

(deleted)

view this post on Zulip Pat Hickey (Dec 03 2023 at 04:21):

Oh that’s my bad

view this post on Zulip Pat Hickey (Dec 03 2023 at 04:21):

Does command not include that?

view this post on Zulip Pat Hickey (Dec 03 2023 at 04:23):

That interface is new in a pretty recent refactoring, we moved existing stuff to a new interface

view this post on Zulip Banna Jack (Dec 06 2023 at 00:53):

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