Skip to content

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

@SetZero

Description

@SetZero

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:

"failed to rename `{}` to `{}`",

And the path only supports release and debug:

path.push(if is_release { "release" } else { "debug" });

(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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions