tauri-apps / tauri

Build smaller, faster, and more secure desktop applications with a web frontend.
https://tauri.app
Apache License 2.0
79.58k stars 2.36k forks source link

[bug] `tauri build` not supporting nightly -Z bindeps #10132

Closed kristoferfannar-ks closed 1 week ago

kristoferfannar-ks commented 1 week ago

Describe the bug

It seems that using the nightly RFC-3028, bindeps, to add binaries as build-dependencies makes my tauri application unable to build.

The specific command I'm using is:

cargo +nightly build -p tauri-app -Z bindeps

Which results in this error:

❯ cargo +nightly build -p tauri-app -Z bindeps
   Compiling tauri-app v0.0.0 (/<dirs>/tauri-bin-builder/crates/tauri-app)
error: failed to run custom build command for `tauri-app v0.0.0 (/<dirs>/tauri-bin-builder/crates/tauri-app)`

Caused by:
  process didn't exit successfully: `/<dirs>/tauri-bin-builder/target/debug/build/tauri-app-c16440941532fbd4/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=TAURI_CONFIG
  cargo:rerun-if-changed=tauri.conf.json
  cargo:rustc-cfg=desktop
  cargo:rustc-cfg=dev
  cargo metadata command exited with a non zero exit code: error: failed to parse manifest at `/<dirs>/tauri-bin-builder/crates/tauri-app/Cargo.toml`

  Caused by:
    `artifact = …` requires `-Z bindeps` (bin_crate)

Running cargo +nightly tauri build -Z bindeps directly results in this error:

❯ cargo +nightly tauri build -Z bindeps
error: unexpected argument '-Z' found

  tip: to pass '-Z' as a value, use '-- -Z'

Usage: cargo tauri build [OPTIONS] [ARGS]...

For more information, try '--help'

The error directly above makes me think that Tauri doesn't support nightly flags, but as I've found no documentation supporting that, I decided to write up this issue just in case.

Reproduction

Minimal reproduction can be found in this repository: https://github.com/kristoferfannar-ks/tauri-bin-example

Steps to reproduce are in README

Expected behavior

I'd except the tauri application to compile the binary crate while building and finish compilation successfully.

Full tauri info output

# from within my example reproduction repo
❯ cargo tauri info
WARNING: no lock files found, defaulting to npm

[✔] Environment
    - OS: Mac OS 14.5.0 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.78.0 (9b00956e5 2024-04-29)
    ✔ cargo: 1.78.0 (54d8815d0 2024-03-26)
    ✔ rustup: 1.27.1 (2024-04-24)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (environment override by RUSTUP_TOOLCHAIN)
    - node: 22.2.0
    - npm: 10.7.0

[-] Packages
    - tauri [RUST]: 1 (no lockfile)
    - tauri-build [RUST]: no manifest (no lockfile)
    - wry [RUST]: no manifest (no lockfile)
    - tao [RUST]: no manifest (no lockfile)
    - tauri-cli [RUST]: 1.5.14
    - @tauri-apps/api : not installed!
    - @tauri-apps/cli [NPM]: 1.5.14

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: web
    - devPath: web

Stack trace

nothing that hasn't already been added

Additional context

Maybe this shouldn't be classified as a bug, as it might simply just not be implemented. Anyways, thanks for the time and attention!

FabianLars commented 1 week ago

We rely on the cargo metadata command in the build script and it looks like it doesn't accept nightly flags (we're not forwarding them right now, but if we would it still shouldn't work). Can you try this instead? https://github.com/rust-lang/rustfmt/issues/5332#issuecomment-1119990254

kristoferfannar-ks commented 1 week ago

You're correct, that worked!

# .cargo/config.toml

[unstable]
bindeps = true

Is enough to build the tauri app with binary dependencies

Running cargo +nightly build -p tauri-app -Z bindeps now builds, with the binary dependency built as well. Of course, cargo +nightly tauri build -Z bindeps still doesn't accept the -Z flag.

Thank you!

FabianLars commented 1 week ago

Of course, cargo +nightly tauri build -Z bindeps still doesn't accept the -Z flag.

Generally you can try cargo +nightly tauri build -- -Z bindeps - This way tauri will forward the args to the cargo build call but not to cargo metadata. That said, with the config.toml setting the -Z bindeps flag shouldn't be required anymore iirc 🤔

kristoferfannar-ks commented 1 week ago

Yes you're correct. -Z bindeps is no longer required with these changes in the config.toml.