Skip to content

[bug] When using a global build.target-dir for Cargo, cargo tauri dev panics at 'failed to rename app'. #4632

@dsaghliani

Description

@dsaghliani

Describe the bug

When using a global target-dir for all projects (instead of storing the builds in the project folder, Cargo writes to ~/.cargo_builds), cargo tauri dev panics, because "no such file or directory" exists. At a guess, the build script doesn't expand to the full path and ends up looking for a local .cargo_builds.

Reproduction

  1. Go to the Cargo installation (on Linux, ~/.cargo).
  2. Create config.toml if it doesn't already exist.
  3. Add the following inside:
[build]
target-dir = ".cargo_builds"
  1. Create a sample front end. In my case, I used Vite with Svelte.
  2. Initialize the Tauri back end.
  3. Configure the build settings in src-tauri/tauri.conf.json.
  4. Run cargo tauri dev.

Expected behavior

The project should build and a Tauri app window should open. This happens when not using a global target-dir.

Platform and versions

Environment
  › OS: Pop!_OS 22.04 X64
  › Node.js: 18.2.0
  › npm: 8.9.0
  › pnpm: Not installed!
  › yarn: Not installed!
  › rustup: 1.24.3
  › rustc: 1.61.0
  › cargo: 1.61.0
  › Rust toolchain: stable-x86_64-unknown-linux-gnu 

Packages
  › @tauri-apps/cli [NPM]: 1.0.3
  › @tauri-apps/api [NPM]: Not installed!
  › tauri [RUST]: 1.0.3,
  › tauri-build [RUST]: 1.0.3,
  › tao [RUST]: 0.12.1,
  › wry [RUST]: 0.19.0,

App
  › build-type: bundle
  › CSP: unset
  › distDir: ../dist
  › devPath: http://localhost:3000/
  › framework: Svelte

App directory structure
  ├─ src-tauri
  ├─ node_modules
  ├─ public
  ├─ .vscode
  ├─ dist
  └─ src

Stack trace

thread '<unnamed>' panicked at 'failed to rename app: failed to rename `.cargo_builds/debug/app` to `.cargo_builds/debug/ff-filter-svelte`

Caused by:
    No such file or directory (os error 2)', /home/dsaghliani/.cargo/registry/src/github.com-1ecc6299db9ec823/tauri-cli-1.0.3/src/interface/rust.rs:340:58
stack backtrace:
   0:     0x56540dc488e1 - std::backtrace_rs::backtrace::libunwind::trace::h22893a5306c091b4
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x56540dc488e1 - std::backtrace_rs::backtrace::trace_unsynchronized::h29c3bc6f9e91819d
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x56540dc488e1 - std::sys_common::backtrace::_print_fmt::he497d8a0ec903793
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x56540dc488e1 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9c2a9d2774d81873
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x56540da69dbc - core::fmt::write::hba4337c43d992f49
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/fmt/mod.rs:1194:17
   5:     0x56540dc1aa54 - std::io::Write::write_fmt::heb73de6e02cfabed
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/io/mod.rs:1655:15
   6:     0x56540dc4b39a - std::sys_common::backtrace::_print::h63c8b24acdd8e8ce
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x56540dc4b39a - std::sys_common::backtrace::print::h426700d6240cdcc2
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x56540dc4b39a - std::panicking::default_hook::{{closure}}::hc9a76eed0b18f82b
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:295:22
   9:     0x56540dc4b049 - std::panicking::default_hook::h2e88d02087fae196
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:314:9
  10:     0x56540dc4bf3a - std::panicking::rust_panic_with_hook::habfdcc2e90f9fd4c
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:698:17
  11:     0x56540dc4be52 - std::panicking::begin_panic_handler::{{closure}}::he054b2a83a51d2cd
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:588:13
  12:     0x56540dc4bdc6 - std::sys_common::backtrace::__rust_end_short_backtrace::ha48b94ab49b30915
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:138:18
  13:     0x56540dc4bd82 - rust_begin_unwind
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:584:5
  14:     0x56540d9d5582 - core::panicking::panic_fmt::h366d3a309ae17c94
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:143:14
  15:     0x56540d9d5782 - core::result::unwrap_failed::hddd78f4658ac7d0f
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/result.rs:1785:5
  16:     0x56540dcef5b1 - tauri_cli::interface::rust::Rust::run_dev::{{closure}}::he4c69b810725a924
  17:     0x56540dceea5e - std::sys_common::backtrace::__rust_begin_short_backtrace::hd6fc1b3325984561
  18:     0x56540dce6102 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h59cc13437e0b1ac9
  19:     0x56540dc4df05 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha99802c2c52ada61
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/alloc/src/boxed.rs:1861:9
  20:     0x56540dc4df05 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha39aea1c57e28a15
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/alloc/src/boxed.rs:1861:9
  21:     0x56540dc4df05 - std::sys::unix::thread::Thread::new::thread_start::h9f8e3d72b1f7662f
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys/unix/thread.rs:108:17
  22:     0x7fd3a7b4bb43 - <unknown>
  23:     0x7fd3a7bdda00 - <unknown>
  24:                0x0 - <unknown>

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: 2 mediumE.g. DX regressions, bugs, dev crashes, etc...scope: cliThe tauri-cli rust crate and @tauri-apps/cli npm packagestatus: backlogIssue is ready and we can work on ittype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions