tauri-apps / tauri

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

[bug] Setting a Custom Profile Will Fail to Rename the Executable on Build #6954

Closed SetZero closed 8 months ago

SetZero commented 1 year ago

Describe the bug

When you setup a build with a custom profile the build will fail with the message:

Error failed to rename `F:\app\src-tauri\target\release\app.exe` to `F:\app\src-tauri\target\release\MyFancyApp.exe`:

This is because the app will be stored in F:\app\src-tauri\target\[PROFILE]\app.exe and not always release.

From what I can see the error message is from this line: https://github.com/tauri-apps/tauri/blob/441f96465488a4f8a5731cc51b8ac97b685898c7/tooling/cli/src/interface/rust/desktop.rs#L372

And the path only supports release and debug: https://github.com/tauri-apps/tauri/blob/441f96465488a4f8a5731cc51b8ac97b685898c7/tooling/cli/src/interface/rust.rs#L946

(I might be wrong, as I haven't looked that much into the code, so take that with a grain of salt)

Reproduction

Create a custom profile in Cargo.toml:

[profile.optimized]
inherits = "release"
lto = true
codegen-units = 1

Build you custom profile:

cargo tauri build -- --profile optimized
Compiling app v0.1.2 (F:\app\src-tauri)
    Finished optimized [optimized + debuginfo] target(s) in 1m 10s
       Error failed to rename `F:\app\src-tauri\target\release\app.exe` to `F:\app\src-tauri\target\release\MyFancyApp.exe`: The system cannot find the file specified. (os error 2)

The app will be stored in F:\app\src-tauri\target\optimized\app.exe

Expected behavior

The build should be able to rename the file

Platform and versions

[✔] Environment
    - OS: Windows 10.0.22621 X64
    ✔ WebView2: 109.0.1518.70
    ✔ MSVC:
        - Visual Studio Build Tools 2022
        - Visual Studio Community 2022
    ✔ rustc: 1.68.2 (9eb3afe9e 2023-03-27)
    ✔ Cargo: 1.68.2 (6feb7c9cf 2023-03-26)
    ✔ rustup: 1.23.1 (3df2264a9 2020-11-30)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (environment override by RUSTUP_TOOLCHAIN)
    - node: 16.1.0
    - yarn: 1.22.10
    - npm: 8.9.0

[-] Packages
    - tauri [RUST]: 1.3.0
    - tauri-build [RUST]: 1.3.0
    - wry [RUST]: 0.24.1
    - tao [RUST]: 0.16.0
    - @tauri-apps/api [NPM]: 1.2.0
    - @tauri-apps/cli [NPM]: 1.3.1

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: http://localhost:5173/
    - framework: React
    - bundler: Vite

### Stack trace

```text
-

Additional context

No response

DrChat commented 8 months ago

Note - this is still not fixed. Cargo uses profile dev to represent debug builds, but they are stored in target/debug instead of target/dev as the code expects.

FabianLars commented 8 months ago

Just to understand this correctly, you're using --profile dev as an alias for the --debug flag (or in vanilla cargo, omitting the --release flag) and that's not working?

DrChat commented 8 months ago

Yup exactly. I'm doing that because I'm using another tool (cargo-make) to invoke Tauri, and that one only has knowledge of Cargo profiles.

DrChat commented 8 months ago

Thank you for the quick fix!