sunfishcode / hello-wasi-http

48 stars 17 forks source link

import `wasi:io/streams@0.2.0-rc-2023-10-18` has the wrong type #5

Closed oovm closed 5 months ago

oovm commented 7 months ago

I cannot execute the project successfully

Here are my steps:

wasmtime-cli 17.0.0 (3b61c511a 2023-12-08)
manifest uses an older version of `cargo-component-bindings` (0.4.1) than cargo-component (0.5.0); use `cargo component upgrade --no-install` to update the manifest

no problem, update to 0.5.0

Error: import `wasi:io/streams@0.2.0-rc-2023-10-18` has the wrong type

Caused by:
    0: instance export `output-stream` has the wrong type
    1: expected resource found nothing
rperez95 commented 6 months ago

Hi,

With wasmtime v16.0.0 (6613acd1e 2023-12-20) it happens more or less the same

When I execute the hello-wasi-http.wasm as follows wasmtime serve target/wasm32-wasi/debug/hello_wasi_http.wasm

I get the following error:

Error: import `wasi:cli/environment@0.2.0-rc-2023-12-05` has the wrong type

Caused by:
    0: instance export `get-environment` has the wrong type
    1: expected func found nothing

@sunfishcode any update on this?

ereslibre commented 5 months ago

Hello @rperez95!

I was experimenting this problem as well, but seems that adding the -Scommon flag to the serve command helped. It adds the preview_2::command to the linker.

So, doing wasmtime serve -Scommon target/wasm32-wasi/debug/hello_wasi_http.wasm should fix the issue.

Although the error is similar to the reported issue originally, I think they are different issues.

rperez95 commented 5 months ago

Hi @ereslibre!

Adding the -Scommon flag to the wasmtime serve command fixed the issue. Now it works perfectly!

Thx!

sunfishcode commented 5 months ago

Yes, -Scommon may work as a workaround. I'm investigating that and working on updating this repo to Wasmtime 17 and Preview 2 in https://github.com/sunfishcode/hello-wasi-http/pull/7.

sunfishcode commented 5 months ago

I believe this is now fixed by #7, which updates the repo to Preview2 and Wasmtime 17. Please re-open this or file new issues if anything doesn't work!