tauri-apps/tauri-bindgen

`tauri_bindgen_host::generate` macro fails when .wit file has CRLF line endings

bravely-beep opened this issue · 2 comments

My setup is:

bindings.wit

interface greet {
    func greet(name: string) -> string
}

src_tauri/src/main.rs

tauri_bindgen_host::generate!({
    path: "../bindings.wit",
});

If bindings.wit has LF line endings, this works with no errors. If the file has CRLF line endings, the tauri_bindgen_host::generate macro panics with this message:

proc macro panicked
message: called `Result::unwrap()` on an `Err` value: wit_parser::unexpected_token

  × expected an identifier, but found 'func'
   ╭─[src\modkit-tauri\src-tauri\../bindings.wit:1:1]
 1 │ interface greet {
 2 │     func greet(name: string) -> string
   ·     ──┬─
   ·       ╰── unexpected token
 3 │ }
   ╰────

Hey @bravely-beep if you have a spare second could you check if the linked PR correctly fixes your issue? I tried to test myself by creating a file with crlf line endings but I'm not 100% confident this works everywhere

tested it on Windows and Mac with CLRF and fixed the error.