Stream: cargo-component

Topic: Latest cargo component errors when building hello-wasi-http


view this post on Zulip Daniel Macovei (Mar 04 2024 at 16:01):

Looking into it but when I try to build hello-wasi-http with the latest release i get the following error several times

error[internal]: left behind trailing whitespace
    --> <stdin>:6490:6490:1
     |
6490 |
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |

followed by

thread 'main' panicked at /Users/interpretations/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wit-bindgen-rust-0.20.0/src/lib.rs:1107:13:
assertion failed: status.success()
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

From what I can tell it seems that wit-bindgen is struggling specifically with wasi:http/proxy... seems to handle the other wasi interfaces just fine.

Contribute to sunfishcode/hello-wasi-http development by creating an account on GitHub.

view this post on Zulip Peter Huene (Mar 04 2024 at 16:10):

Ugh, it's unfortunate we're not gracefully handling rustfmt failure exit status in wit-bindgen-rust. Not sure why rustfmt is failing, but it's probably something that can be worked around if wit-bindgen wasn't generating trailing whitespace; I'd start by filing an issue in wit-bindgen.

You can work around this for now in cargo-component by setting package.metadata.component.bindings.format to false in Cargo.toml

view this post on Zulip Daniel Macovei (Mar 04 2024 at 16:11):

Did the trick. Thanks!

view this post on Zulip Daniel Macovei (Mar 04 2024 at 16:11):

Will open that issue

view this post on Zulip Peter Huene (Mar 04 2024 at 16:13):

It looks like Dan might have beat us to the punch: https://github.com/bytecodealliance/wit-bindgen/pull/878

This works around what appears to be a bug in rustfmt when generating bindings for wasi-http. If the code is too complex, rustfmt appears to stops formatting, and then abort when it leaves behind t...

view this post on Zulip Daniel Macovei (Mar 04 2024 at 16:14):

awesome

view this post on Zulip Yoshua Wuyts (Mar 04 2024 at 16:25):

@Peter Huene would it perhaps be an idea to switch from cargo fmt to prettyplease for this?

view this post on Zulip Peter Huene (Mar 04 2024 at 16:25):

ooh, that seems like the right thing to use for wit-bindgen

view this post on Zulip Yoshua Wuyts (Mar 04 2024 at 16:26):

I've used it in html-bindgen before, and it worked surprisingly well!

view this post on Zulip Peter Huene (Mar 04 2024 at 16:27):

do you mind opening an issue in wit-bindgen to switch it over?

view this post on Zulip Yoshua Wuyts (Mar 04 2024 at 16:27):

yep, can do!

view this post on Zulip Peter Huene (Mar 04 2024 at 16:27):

(or just putting up a PR)

view this post on Zulip Peter Huene (Mar 04 2024 at 16:27):

thanks!

view this post on Zulip Yoshua Wuyts (Mar 04 2024 at 16:36):

Filed: https://github.com/bytecodealliance/wit-bindgen/issues/880

In order to more structurally work around code formatting issues like those described in #878, we should consider switching from cargo fmt to Dtolnay's prettyplease crate. This crate was designed s...

Last updated: Nov 25 2024 at 19:03 UTC