Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Improve error messages if cargo metadata fails. #12273

Open
jmetz opened this issue Jan 6, 2025 · 6 comments
Open

[bug] Improve error messages if cargo metadata fails. #12273

jmetz opened this issue Jan 6, 2025 · 6 comments
Labels
good first issue Good for newcomers status: backlog Issue is ready and we can work on it type: bug

Comments

@jmetz
Copy link

jmetz commented Jan 6, 2025

Describe the bug

Running:

cargo create-tauri-app or sh <(curl https://create.tauri.app/sh)

  • Tried rust-based (tried vanilla and leptos) frontend as well as Typescript based (vanilla with pnpm or deno)

then

cargo tauri android init or pnpm tauri android init or deno task tauri android init all produce:

failed to get cargo metadata: expected value at line 1 column 1

Trying cargo tauri dev instead of android init gives the same issue.

Adding verbose flag with -v doesn't give any useful info.

Apologies in advance if this is something trivial I've missed; at the same time, the quickstart should be as foolproof as possible IMO, so this could still highlight an area for improvement.

Reproduction

sh <(curl https://create.tauri.app/sh)
# Select any frontend option
cargo tauri android init 
# OR
cargo tauri dev

Expected behavior

Should android init should create android scaffold, or cargo tauri dev should correctly build app and launch dev server.

Full tauri info output

cargo tauri info


[✔] Environment
    - OS: EndeavourOS Rolling Release x86_64 (X64) (Unknown DE on wayland)
    ✔ webkit2gtk-4.1: 2.46.5
    ✔ rsvg2: 2.59.2
    ✔ rustc: 1.83.0 (90b35a623 2024-11-26)
    ✔ cargo: 
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (environment override by RUSTUP_TOOLCHAIN)
    - node: 20.18.1
    - pnpm: 9.15.3
    - yarn: 1.22.22
    - npm: 11.0.0
    - bun: 1.0.7
    - deno: deno 2.0.6

[-] Packages
    - tauri 🦀: 2
    - tauri-build 🦀: No version detected
    - wry 🦀: No version detected
    - tao 🦀: No version detected
    -  🦀: cargo 1.83.0 (5ffbef321 2024-10-29)
    - @tauri-apps/api : 2.2.0
    - @tauri-apps/cli : 2.2.2

[-] Plugins

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - bundler: Vite

Stack trace

failed to get cargo metadata: expected value at line 1 column 1

Additional context

No response

@jmetz jmetz added status: needs triage This issue needs to triage, applied to new issues type: bug labels Jan 6, 2025
@FabianLars
Copy link
Member

thanks for the report. Since it's missing in the tauri info output for some reason, could you share the output of cargo --version please? Also, how did you install cargo?

@jmetz
Copy link
Author

jmetz commented Jan 6, 2025

Sorry about that - I think the info is above, though only after my edit. cargo was installed with rustup, and the version is

cargo 1.83.0 (5ffbef321 2024-10-29)

(the reason for the odd output above is that I had cargo shadowed by a script that sets RUSTC_WRAPPER=sccache before calling cargo properly, which caused the malformed output of cargo tauri info)

@FabianLars
Copy link
Member

thanks. I just tried it on my system and don't see any issues. Can you share the generated Cargo.toml file?

@jmetz
Copy link
Author

jmetz commented Jan 6, 2025

@FabianLars - Opps! I just renamed my wrapper script and it works fine.

I didn't realise that cargo tauri uses the output of cargo-commands to work; so by adding my wrapper script and slightly modifying that output, it breaks things!

Is it possible to move away from cargo tauri using the CLI output of the cargo command? That said, I can see that that might be tricky or undesirable.

Perhaps this should instead be a request to improve the error message; something about not being able to correctly parse the output of cargo would be more useful than failed to get cargo metadata. That message had me thinking the issue must be in Cargo.toml or something.

@FabianLars
Copy link
Member

in development you can use cargo run just fine. you just have to run the beforeDevCommand yourself in another terminal.

For building apps you can also use cargo build --release plus the beforeBuildCommand but if you also want to bundle them into installers then you need cargo tauri.

Is it possible to move away from cargo tauri using the CLI output of the cargo command? That said, I can see that that might be tricky or undesirable.

This would require us to copy a shit ton of logic out of cargo itself and keeping that up to date, so i'd really rather not tbh, especially since this is the first time it ever caused problems iirc.

But yeah, the error message should be improved (like almost all current error messages...)

@FabianLars FabianLars changed the title [bug] Hello-world quickstart error on linux; tauri-cli command possibly broken [bug] Improve error messages if cargo metadata fails. Jan 6, 2025
@FabianLars FabianLars added good first issue Good for newcomers status: backlog Issue is ready and we can work on it and removed status: needs triage This issue needs to triage, applied to new issues labels Jan 6, 2025
@jmetz
Copy link
Author

jmetz commented Jan 6, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers status: backlog Issue is ready and we can work on it type: bug
Projects
None yet
Development

No branches or pull requests

2 participants