AAP127 opened issue #7505:
I am trying to test making a wasm component using the steps in the wasi-preview1-component-adapter section, provided here. I tried the steps after downloading and renaming both a command and reactor file from the linked downloads.
I am able to create the component seemingly successfully, but then I attempt to run it with wasmtime 15 and get the following error:
Error: failed to run main module `component.wasm` Caused by: 0: import `wasi:io/streams@0.2.0-rc-2023-11-05` has the wrong type 1: instance export `output-stream` has the wrong type 2: expected resource found nothing
I was wondering what part in the process might be going wrong, or if I should be trying to run the component some other way. The end goal is to try and see if I test having modules communicate with each other, and I was thinking component model functions might help (i.e. exporting functions from one module to use in another). Any advice would be appreciated, thanks!
alexcrichton commented on issue #7505:
Can you confirm which Wasmtime version you're using? You're likely running up against a version mismatch between what the adapter wants and what the runtime is expecting. Here for example it seems like the adapter wants
0.2.0-rc-2023-11-05
which I think means that you're using thedev
tag and its adapter. Wasmtime 15, which isn't released yet, implements this. Wasmtime 14, however, which is released, does not implement this version. Hence I want to confirm whether you're using Wasmtime 14 or 15.If you're using Wasmtime 14 then you can download the adapters from here
rkrishn7 commented on issue #7505:
Confirmed that this is occurring for me as well using Wasmtime 14 and the adapter from here.
When inspecting the
wit
interface for my component, all imports are using the following version:0.2.0-rc-2023-10-18
rkrishn7 edited a comment on issue #7505:
Confirmed that this is occurring for me as well using Wasmtime
14.0.4
and the adapter from here.When inspecting the
wit
interface for my component, all imports are using the following version:0.2.0-rc-2023-10-18
alexcrichton commented on issue #7505:
Can you clarify the set of steps you're following to reproduce?
rkrishn7 commented on issue #7505:
@alexcrichton Sure! I created a repo here that contains the code/steps to reproduce.
alexcrichton commented on issue #7505:
Ah @rkrishn7 your example code doesn't link in WASI. The
HelloWorld
structure generated does not contain WASI in it but your component does. WASI comes in through the adapter. You'll want to calladd_to_linker
to pull in all the WASI functions.
rkrishn7 commented on issue #7505:
Ahh that makes sense. Working well now, thanks a bunch! I've pushed an updated commit showing how to correctly link to WASI here.
On a related note, do we think it might be a good idea to make a note of this in the example found here? While it doesn't show the implementation for the guest function, it could be a point of confusion when attempting to build & run the example.
alexcrichton commented on issue #7505:
Perhaps yeah! I'm not sure how best to handle that. For example the world in that snippet does not include WASI, so technically feeding in a component that uses WASI correctly reports an error (the error message can definitely be improved). So from a "what went wrong where" perspective the error is a big higher up than the example because either the world isn't correct or the component isn't correct. From a more practical perspective though almost all components will import WASI, so it would also make sense to showcase there. Hence me not being entirely sure how best to handle this.
rkrishn7 commented on issue #7505:
Yeah, that makes sense. I guess even if it's not fully incorporated into the example, it might be worth mentioning as a side note. Particularly, since
wit_bindgen
references the macro docs when mentioning host runtimes and the provided guest (Rust) example there calls for building using a target ofwasm32-wasi
.
AAP127 commented on issue #7505:
Sorry just to add in, I was using Wasmtime 15 when trying to run the component. $wt15 is the command I have setup to target wastmtime 15 as I previously had installed wasmtime 12, but I do use $wt15 when trying to run the component. Unsure if it is some dev build or similar:
$wt15 --version wasmtime-cli 15.0.0
As for the steps, the link in the original issue was a small writeup at the bottom and I was directly copying each command after downloading and renaming either preview 1 adapter wasm file. Will try the example @rkrishn7 made and see the results of that. Just to clarify, is the issue faced here that the main rust code doesn't actually use wasi functions, or that it does not do some linking correctly? Am a bit unfamiliar with linking and all.
alexcrichton commented on issue #7505:
@AAP127 where did you get Wasmtime 15 from? That isn't published yet so you probably have a particular commit, and that may not be the one inteneded for the adapter being used.
AAP127 commented on issue #7505:
I see. I tried looking back for where I would have found it but can't seem to. I will go ahead and try downloading/ updating to wasmtime 14 and running the code linked above. Would there be any specific procedures needed in terms of component adapters?
alexcrichton commented on issue #7505:
At this time the version of Wasmtime and the adapter must be the same. Effectively the two need to be built from the same source. If you use the release artifacts, for example, that guarantee will be provided.
AAP127 commented on issue #7505:
I see, so to clarify then, instead of using the dev version, I should instead make sure I update to wasmtime 14.x and use the accompanying adapter linked with the version number? Aka get the full version number version of the adapter from here and then ensure my wasmtime version matches whichever one I choose?
alexcrichton commented on issue #7505:
Yep that should work! As of right now the versions must all match. That won't be necessary in the future since we'll start having compatibility across versions but for the time being that's the way to go.
AAP127 commented on issue #7505:
Got it thanks! Will try to use wasmtime 14 and adapter to see if i get better luck with that then,
AAP127 closed issue #7505:
I am trying to test making a wasm component using the steps in the wasi-preview1-component-adapter section, provided here. I tried the steps after downloading and renaming both a command and reactor file from the linked downloads.
I am able to create the component seemingly successfully, but then I attempt to run it with wasmtime 15 and get the following error:
Error: failed to run main module `component.wasm` Caused by: 0: import `wasi:io/streams@0.2.0-rc-2023-11-05` has the wrong type 1: instance export `output-stream` has the wrong type 2: expected resource found nothing
I was wondering what part in the process might be going wrong, or if I should be trying to run the component some other way. The end goal is to try and see if I test having modules communicate with each other, and I was thinking component model functions might help (i.e. exporting functions from one module to use in another). Any advice would be appreciated, thanks!
AAP127 commented on issue #7505:
I ended up using the new release of wasmtime 15 and the corresponding adapter and can now successfully run the component from the example code. Thanks everyone!
MendyBerger commented on issue #7505:
Where do I find what version of wasi I'm supposed to use with a specific version of wasmtime?
Last updated: Nov 22 2024 at 17:03 UTC