Hi,
I'm trying to get a simple preview2 example to work. I have a simple world that imports a few custom things and has a single exported run function. When executing:wasm-tools component new ./target/wasm32-wasi/debug/guest.wasm -o guest.component.wasm --adapt wasi_snapshot_preview1=./wasi_snapshot_preview1.command.wasm
it gives me the following error: duplicate export found for interface run
I can't seem to figure out what the exported function / entrypoint should be called in a world?
How does your wit world look like? And also, how do you want to run your plugin, from wasmtime rust, or from wasmtime cli?
world: `package example:gpio
world my-world {
import types
export run: func() -> result
}`
from wasmtime rust
In that case, you can take a look at how things are done in this example repo, although I have not used that solution myself.
I got a solution working using cargo component
for the plugin, the code can be seen here. Look at the plugin-wasi
and runtime-rust-wasmtime
folders for a full example.
Other than that, I cannot say what is wrong with your setup without seeing the entirety of it.
FYI, we just call what you keep referring to as "plugins" as "guest code" or "guests" officially and in docs. Whether a given guest is a plugin, extension, application, etc. depends on how that guest component is designed to be used and is used in practice.
You're obviously welcome to refer to your own components and guests however you like, but it's a bit confusing when you ask "how do you want to run your plugin" to people just talking about components generally.
the command adapter is just for programs that are CLI style and use _start (which initialize guest libc and then call the user's main). if you are creating your own world, use the reactor adapter
If I use the reactor (with the command I used in my previous message) i get the following error: component-type version 2 does not match supported version 3. I am using wit-bindgen 0.9.0 and wasm-tools 1.0.36.
The reactor is from wasmtime release 10.0.1
Apparently the reactor of wasmtime 10.0.1 is too old.. Used the reactor of wasm-tools (https://github.com/bytecodealliance/wasmtime/releases/tag/dev)
Last updated: Nov 22 2024 at 16:03 UTC