tauri-apps / tauri

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

[bug] `tauri build` ignores `--debug` argument #11768

Closed Phippe closed 5 hours ago

Phippe commented 12 hours ago

Describe the bug

I wanted to debug the release build of my app using devtools, so I ran the command listed here, but it simply created a normal release build. I can't open any devtools, neither by right-clicking and inspecting nor pressing F12.

As far as I remember, this command used to work on Tauri 1.x.

Reproduction

  1. Start a new project with npm create tauri-app@latest and install all the packages
  2. Run npm run tauri build -- --debug

A normal release build will be created in the src-tauri/target/release/bundle directory. A src-tauri/target/debug/bundle folder on the other hand doesn't even exist.

Expected behavior

According to the docs, a new debug build should be created in src-tauri/target/debug/bundle, allowing the use of devtools.

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.22621 x86_64 (X64)
    ✔ WebView2: 130.0.2849.80
    ✔ MSVC: Visual Studio Community 2022
    ✔ rustc: 1.82.0 (f6e511eec 2024-10-15)
    ✔ cargo: 1.82.0 (8f40fc59f 2024-08-21)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 22.11.0
    - pnpm: 8.15.5
    - npm: 10.5.0

[-] Packages
    - tauri 🦀: 2.1.1
    - tauri-build 🦀: 2.0.3
    - wry 🦀: 0.47.2
    - tao 🦀: 0.30.8
    - @tauri-apps/api : 2.1.1
    - @tauri-apps/cli : 2.1.0

[-] Plugins
    - tauri-plugin-shell 🦀: 2.0.2
    - @tauri-apps/plugin-shell : 2.0.1

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - bundler: Vite

Stack trace

No response

Additional context

No response

FabianLars commented 12 hours ago

can you show the terminal messages when you run npm run tauri build -- --debug ? This command should still work in v2.

Phippe commented 12 hours ago
PS D:\phili\dev\debug-build-bug> npm run tauri build -- --debug

> debug-release-build@0.1.0 tauri
> tauri build

    Running beforeBuildCommand `npm run build`

> debug-release-build@0.1.0 build
> tsc && vite build

vite v5.4.11 building for production...
✓ 6 modules transformed.
dist/index.html                 8.36 kB │ gzip: 3.46 kB
dist/assets/index-pSGieOOU.css  1.37 kB │ gzip: 0.65 kB
dist/assets/index-DdG3jFR9.js   1.11 kB │ gzip: 0.59 kB
✓ built in 183ms
   Compiling debug-release-build v0.1.0 (D:\phili\dev\debug-build-bug\src-tauri)
    Finished `release` profile [optimized] target(s) in 50.01s
    Built application at: D:\phili\dev\debug-build-bug\src-tauri\target\release\debug-release-build.exe
    Info Target: x64
    Running candle for "main.wxs"
    Running light to produce D:\phili\dev\debug-build-bug\src-tauri\target\release\bundle\msi\debug-release-build_0.1.0_x64_en-US.msi
    Info Target: x64
    Running makensis.exe to produce D:\phili\dev\debug-build-bug\src-tauri\target\release\bundle\nsis\debug-release-build_0.1.0_x64-setup.exe
    Finished 2 bundles at:
        D:\phili\dev\debug-build-bug\src-tauri\target\release\bundle\msi\debug-release-build_0.1.0_x64_en-US.msi
        D:\phili\dev\debug-build-bug\src-tauri\target\release\bundle\nsis\debug-release-build_0.1.0_x64-setup.exe
FabianLars commented 12 hours ago

thanks. Can you also share the scripts section in package.json?

Phippe commented 12 hours ago

Should be short enough, so here's the whole package.json in case anything else is needed:

{
  "name": "debug-release-build",
  "private": true,
  "version": "0.1.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "tsc && vite build",
    "preview": "vite preview",
    "tauri": "tauri"
  },
  "dependencies": {
    "@tauri-apps/api": "^2",
    "@tauri-apps/plugin-shell": "^2"
  },
  "devDependencies": {
    "@tauri-apps/cli": "^2",
    "vite": "^5.3.1",
    "typescript": "^5.2.2"
  },
  "packageManager": "pnpm@8.15.5+sha1.a58c038faac410c947dbdb93eb30994037d0fce2"
}
FabianLars commented 9 hours ago

and tauri dev still works fine? If not then something like a .cargo/config.toml that somehow forces release mode (if that exists) could have been possible, but if that works i really have no idea what the issue could be. Maybe try updating npm, or try yarn or pnpm?

Right now you're the only person with this issue so there has to be something system specific i can't think of here 🤔

Phippe commented 7 hours ago

So, I've just tried different versions of Node and found some success with older versions:

(tauri dev works fine, if this is still of relevance now)

FabianLars commented 5 hours ago

There seem to be more people with the problem in the npm repo.

Mentioned workarounds include npm run tauri build "--" --debug and npm run tauri build -- -- --debug

I still wonder why this seems to be only affecting a handful of users 🤔