tauri-apps / tauri

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

[bug] Using "--target-dir" with tauri build causes "failed to rename app: failed to rename" #10190

Open Geometrically opened 3 days ago

Geometrically commented 3 days ago

Describe the bug

I'm using this command to build and run my tauri project:

Reproduction

  1. Create a new tauri project
  2. Use build command with custom target directory. Ex: pnpm run tauri build -- --target-dir $NX_WORKSPACE_ROOT/dist/target/theseus_gui_rs
  3. Command will fail with errror "failed to rename app: failed to rename" (see full error below)

Expected behavior

Project is built/served without any error.

Full tauri info output

[✔] Environment
    - OS: Mac OS 15.0.0 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.79.0 (129f3b996 2024-06-10)
    ✔ cargo: 1.79.0 (ffa9cf99a 2024-06-03)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 18.15.0
    - pnpm: 9.0.6
    - yarn: 3.5.1
    - npm: 9.5.0

[-] Packages
    - tauri [RUST]: 1.7.1
    - tauri-build [RUST]: 1.5.3
    - wry [RUST]: 0.24.10
    - tao [RUST]: 0.16.9
    - @tauri-apps/api [NPM]: 1.6.0
    - @tauri-apps/cli [NPM]: 1.6.0

[-] App
    - build-type: bundle
    - CSP: default-src 'self'; connect-src https://modrinth.com https://*.modrinth.com https://mixpanel.com https://*.mixpanel.com https://*.cloudflare.com https://api.mclo.gs; font-src https://cdn-raw.modrinth.com/fonts/inter/; img-src tauri: https: data: blob: 'unsafe-inline' asset: https://asset.localhost; script-src https://*.cloudflare.com 'self'; frame-src https://*.cloudflare.com https://www.youtube.com https://www.youtube-nocookie.com https://discord.com 'self'; style-src unsafe-inline 'self'
    - distDir: ../../dist/apps/theseus-gui
    - devPath: http://localhost:1420/
    - framework: Vue.js (Nuxt)
    - bundler: Rollup

Stack trace

thread '<unnamed>' panicked at src/interface/rust/desktop.rs:52:69:
failed to rename app: failed to rename `/Users/geometrically/Documents/Coding/modrinth/monorepo/dist/target/debug/theseus_gui_rs` to `/Users/geometrically/Documents/Coding/modrinth/monorepo/dist/target/debug/Modrinth App`

Caused by:
    No such file or directory (os error 2)

Additional context

We are using NX for our application's monorepo. We are using custom target directories for their caching functionality.

FabianLars commented 3 days ago

We are using NX for our application's monorepo. We are using custom target directories for their caching functionality.

Does using a .cargo/config.toml file for the target-dir setting also work for this? Because that is supported by tauri.

Edit: The CARGO_TARGET_DIR environment variable should work too.