tauri: Cannot run a new app on Windows

Describe the bug

A clear and concise description of what the bug is. This is probably the same thing happening in #2867

To Reproduce

Steps to reproduce the behavior: TLDR; follow the tauri website

  1. Run yarn create tauri-app
  2. cd tauri-app (or whatever you called it)
  3. Run yarn tauri info
  4. Run yarn tauri dev <- errors
  5. Try it again… fails again

Expected behavior

Tauri app compiles & runs

Platform and Versions (required):

tauri-app> yarn tauri info
yarn run v1.22.17
$ tauri info
 app:spawn Running "C:\...\tauri-app\node_modules\@tauri-apps\cli\bin\tauri-cli.exe tauri info" +0ms


Operating System - Windows, version 10.0.19042 X64
Webview2 - 95.0.1020.44

Node.js environment
  Node.js - 16.13.0
  @tauri-apps/cli - 1.0.0-beta.10
  @tauri-apps/api - 1.0.0-beta.8

Global packages
  npm - 8.1.2
  yarn - 1.22.17

Rust environment
  rustc - 1.56.1
  cargo - 1.56.0

App directory structure
/.vscode
/node_modules
/public
/src
/src-tauri

App
  tauri.rs - 1.0.0-beta.8 (no lockfile)
  build-type - bundle
  CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  distDir - ../public
  devPath - http://localhost:5000
  framework - Svelte
  bundler - Rollup

Done in 10.38s.

Additional context

Fresh install

Stack Trace

> yarn tauri dev
yarn run v1.22.17
$ tauri dev
 app:spawn Running "C:\...\tauri-app\node_modules\@tauri-apps\cli\bin\tauri-cli.exe tauri dev" +0ms

[tauri:dev] Running `npm run dev`

> tauri-app@1.0.0 dev
> rollup -c -w

    Updating crates.io index
rollup v2.59.0
bundles src/main.ts β†’ public\build\bundle.js...
LiveReload enabled
created public\build\bundle.js in 1.4s

[2021-11-10 12:04:44] waiting for changes...

> tauri-app@1.0.0 start
> sirv public --no-clear "--dev"


  Your application is ready~! πŸš€

  ➑ Port 5000 is taken; using 61291 instead

  - Local:      http://localhost:61291
  - Network:    Add `--host` to expose

────────────────── LOGS ──────────────────

   Compiling cfg-if v1.0.0
   Compiling proc-macro2 v1.0.32
   Compiling unicode-xid v0.2.2
  
   ...snip...

   Compiling tauri-utils v1.0.0-beta.3
   Compiling tauri-build v1.0.0-beta.4
   Compiling tauri-codegen v1.0.0-beta.4
   Compiling tauri-runtime v0.2.1
   Compiling tauri-runtime-wry v0.2.1
   Compiling app v0.1.0 (C:\...\tauri-app\src-tauri)
   Compiling tauri-macros v1.0.0-beta.5
error: failed to run custom build command for `app v0.1.0 (C:\...\tauri-app\src-tauri)`

Caused by:
  process didn't exit successfully: `C:\...\tauri-app\src-tauri\target\debug\build\app-2b5a73ef3a83e3f7\build-script-build` (exit code: 101)
  --- stdout
  package.metadata does not exist
  Selected RC path: 'bin\x64\rc.exe'

  --- stderr
  thread 'main' panicked at 'error found during tauri-build: failed to compile `icons/icon.ico` into a Windows Resource file during tauri-build', C:\...\.cargo\registry\src\github.com-1ecc6299db9ec823\tauri-build-1.0.0-beta.4\src\lib.rs:88:5
  stack backtrace:
     0: std::panicking::begin_panic_handler
               at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35\/library\std\src\panicking.rs:517
     1: std::panicking::begin_panic_fmt
               at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35\/library\std\src\panicking.rs:460
     2: tauri_build::build
               at C:\...\.cargo\registry\src\github.com-1ecc6299db9ec823\tauri-build-1.0.0-beta.4\src\lib.rs:88
     3: build_script_build::main
               at .\src\build.rs:2
     4: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
               at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35\library\core\src\ops\function.rs:227
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
warning: build failed, waiting for other jobs to finish...
error: build failed

Try 2:

> yarn tauri dev
yarn run v1.22.17
$ tauri dev
 app:spawn Running "C:\...\tauri-app\node_modules\@tauri-apps\cli\bin\tauri-cli.exe tauri dev" +0ms

[tauri:dev] Running `npm run dev`

> tauri-app@1.0.0 dev
> rollup -c -w

   Compiling app v0.1.0 (C:\...\tauri-app\src-tauri)
error: failed to run custom build command for `app v0.1.0 (C:\...\tauri-app\src-tauri)`

Caused by:
  process didn't exit successfully: `C:\...\tauri-app\src-tauri\target\debug\build\app-2b5a73ef3a83e3f7\build-script-build` (exit code: 101)
  --- stdout
  package.metadata does not exist
  Selected RC path: 'bin\x64\rc.exe'

  --- stderr
  thread 'main' panicked at 'error found during tauri-build: failed to compile `icons/icon.ico` into a Windows Resource file during tauri-build', C:\...\.cargo\registry\src\github.com-1ecc6299db9ec823\tauri-build-1.0.0-beta.4\src\lib.rs:88:5
  stack backtrace:
     0: std::panicking::begin_panic_handler
               at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35\/library\std\src\panicking.rs:517
     1: std::panicking::begin_panic_fmt
               at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35\/library\std\src\panicking.rs:460
     2: tauri_build::build
               at C:\...\.cargo\registry\src\github.com-1ecc6299db9ec823\tauri-build-1.0.0-beta.4\src\lib.rs:88
     3: build_script_build::main
               at .\src\build.rs:2
     4: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
               at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35\library\core\src\ops\function.rs:227
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
rollup v2.59.0
bundles src/main.ts β†’ public\build\bundle.js...
LiveReload enabled
created public\build\bundle.js in 1.3s

[2021-11-10 12:18:23] waiting for changes...

> tauri-app@1.0.0 start
> sirv public --no-clear "--dev"


  Your application is ready~! πŸš€

  ➑ Port 5000 is taken; using 54591 instead

  - Local:      http://localhost:54591
  - Network:    Add `--host` to expose

────────────────── LOGS ──────────────────

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 29 (17 by maintainers)

Commits related to this issue

Most upvoted comments

Root cause

The error is produced by an incorrect RC path (like @lucasfernog suggested). The winres crate returns a default path, bin\x64\rc.exe when it cannot determine a real location. In my case, a real location could not be determined because company IT security has restricted registry viewing. Said differently winres cannot read my registry key HKLM\SOFTWARE\Microsoft\Windows Kits\Installed Roots so it defaults to bin/x64/rc.exe. This is not the correct path.

The Solution

If I edit how I’m calling winres to below, then things start working:

  let mut res = winres::WindowsResource::new();
  res.set_toolkit_path("C:/Program Files (x86)/Windows Kits/10/bin/10.0.19041.0/x64/");

I verified this by running a hard-coded version of tauri-build that had this path in it.

The two fixes i propose are:

  1. winres probably needs a warning if the path isn’t found and it is using defaults
  2. tauri-build needs a new config parameter to allow me to pass in the right rc path.

I’ll get to work on these PRs right away.

PS C:\data-gui> rustup show

rustup home:  C:\.rustup

stable-x86_64-pc-windows-msvc (default)
rustc 1.73.0 (cc66ad468 2023-10-03)


PS C:\data-gui> npm run tauri info

> data-gui@0.0.0 tauri
> tauri info

[βœ”] Environment
    - OS: Windows 10.0.19045 X64
    βœ” WebView2: 117.0.2045.60
    βœ” MSVC: Visual Studio Build Tools 2022
    βœ” rustc: 1.72.0 (5680fa18f 2023-08-23)
    βœ” Cargo: 1.72.0 (103a7ff2e 2023-08-15)
    - node: 20.8.0
    - yarn: 1.22.19
    - npm: 10.1.0

[-] Packages
    - tauri [RUST]: 1.5.1
    - tauri-build [RUST]: 1.5.0
    - wry [RUST]: 0.24.4
    - tao [RUST]: 0.16.4
    - tauri-cli [RUST]: not installed!
    - @tauri-apps/api [NPM]: 1.5.0
    - @tauri-apps/cli [NPM]: 1.5.2

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



PS C:\data-gui> yarn tauri dev
yarn run v1.22.19
$ tauri dev
     Running BeforeDevCommand (`yarn dev`)
$ vite

  VITE v4.4.11  ready in 4431 ms

  ➜  Local:   http://localhost:1420/
  ➜  Network: use --host to expose  
        Warn Waiting for your frontend dev server to start on http://localhost:1420/...
        Info Watching C:\data-gui\src-tauri for changes...
    Blocking waiting for file lock on package cache

   Compiling tauri-runtime v0.14.1

   Compiling wry v0.24.4

   Compiling data-gui v0.0.0 (C:\data-gui\src-tauri)

error: failed to run custom build command for `data-gui v0.0.0 (C:\data-gui\src-tauri)`



Caused by:

  process didn't exit successfully: `C:\data-gui\src-tauri\target\debug\build\data-gui-0628a3d1102c55b8\build-script-build` (exit code: 101)

  --- stdout

  cargo:rerun-if-env-changed=TAURI_CONFIG

  cargo:rerun-if-changed=tauri.conf.json

  cargo:rustc-cfg=desktop

  cargo:rustc-cfg=dev

  package.metadata does not exist



  --- stderr

  thread 'main' panicked at 'Couldn't to execute windres to compile "C:\data-gui\src-tauri\target\debug\build\data-gui-438dbf4e2fa80abf\out\resource.rc" into "C:\data-gui\src-tauri\target\debug\build\data-gui-438dbf4e2fa80abf\out/libresource.a": program not found', C:\.cargo\registry\src\index.crates.io-6f17d22bba15001f\embed-resource-2.4.0\src\windows_not_msvc.rs:49:23

  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

warning: build failed, waiting for other jobs to finish...

error Command failed with exit code 101.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Do I really have a config issue? Looks good to me, no?!

I’m getting this error and I don’t know how to fix it. I don’t know how to apply the above fix as I am new to Rust/Tauri.