tauri-apps / tauri

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

Fresh install on windows 11 fails to run. #8210

Open mendrik opened 12 months ago

mendrik commented 12 months ago

Describe the bug

C:\Desk\mendrik\gridmail [(master)]> pnpm tauri dev

gridmail@0.0.0 tauri C:\Desk\mendrik\gridmail tauri "dev"

 Running BeforeDevCommand (`pnpm dev`)

gridmail@0.0.0 dev C:\Desk\mendrik\gridmail vite

VITE v4.5.0 ready in 1527 ms

➜ Local: http://localhost:1420/ ➜ Network: use --host to expose Info Watching C:\Desk\mendrik\gridmail\src-tauri for changes... Compiling gridmail v0.0.0 (C:\Desk\mendrik\gridmail\src-tauri) error: failed to run custom build command for gridmail v0.0.0 (C:\Desk\mendrik\gridmail\src-tauri)

Caused by: process didn't exit successfully: C:\Desk\mendrik\gridmail\src-tauri\target\debug\build\gridmail-c6d3a36e1f6fd448\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 C:\Users\andre.cargo\registry\src\index.crates.io-6f17d22bba15001f\embed-resource-2.4.0\src\windows_not_msvc.rs:49:23: Couldn't to execute windres to compile "C:\Desk\mendrik\gridmail\src-tauri\target\debug\build\gridmail-7730a8fa1494b3ce\out\resource.rc" into "C:\Desk\mendrik\gridmail\src-tauri\target\debug\build\gridmail-7730a8fa1494b3ce\out/libresource.a": program not found note: run with RUST_BACKTRACE=1 environment variable to display a backtrace  ELIFECYCLE  Command failed with exit code 4294967295.  ELIFECYCLE  Command failed with exit code 101.

Reproduction

Well I followed the readme, step by step and got this when I chose preact + typescript

Expected behavior

It should probably launch a window.

Platform and versions

> tauri "info"

[✔] Environment
    - OS: Windows 10.0.22631 X64
    ✔ WebView2: 119.0.2151.44
    ✔ MSVC: Visual Studio Build Tools 2022
    ✔ rustc: 1.73.0 (cc66ad468 2023-10-03)
    ✔ cargo: 1.73.0 (9c4383fb5 2023-08-26)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 21.1.0
    - pnpm: 8.10.2
    - npm: 10.2.0

[-] Packages
    - tauri [RUST]: 1.5.2
    - tauri-build [RUST]: 1.5.0
    - wry [RUST]: 0.24.4
    - tao [RUST]: 0.16.5
    - @tauri-apps/api [NPM]: 1.5.1
    - @tauri-apps/cli [NPM]: 1.5.6

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: http://localhost:1420/
    - framework: React // I have chosen preact, though
    - bundler: Vite

Stack trace

Caused by:
  process didn't exit successfully: `C:\Desk\mendrik\gridmail\src-tauri\target\debug\build\gridmail-c6d3a36e1f6fd448\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 C:\Users\andre\.cargo\registry\src\index.crates.io-6f17d22bba15001f\embed-resource-2.4.0\src\windows_not_msvc.rs:49:23:
  Couldn't to execute windres to compile "C:\Desk\mendrik\gridmail\src-tauri\target\debug\build\gridmail-7730a8fa1494b3ce\out\resource.rc" into "C:\Desk\mendrik\gridmail\src-tauri\target\debug\build\gridmail-7730a8fa1494b3ce\out/libresource.a": program not found
  stack backtrace:
     0:     0x7ff6d8d5036c - std::backtrace_rs::backtrace::dbghelp::trace::h782acb12622401a5
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\..\..\backtrace\src\backtrace/dbghelp.rs:98:5
     1:     0x7ff6d8d5036c - std::backtrace_rs::backtrace::trace_unsynchronized::h863bea32e8b4cd40
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\..\..\backtrace\src\backtrace/mod.rs:66:5
     2:     0x7ff6d8d5036c - std::sys_common::backtrace::_print_fmt::h8e00824771791c97
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common/backtrace.rs:67:5
     3:     0x7ff6d8d5036c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he79a180599bd168b
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common/backtrace.rs:44:22
     4:     0x7ff6d8db233b - core::fmt::rt::Argument::fmt::h8c61f2ec76e1ae1c
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\core\src\fmt/rt.rs:138:9
     5:     0x7ff6d8db233b - core::fmt::write::h8b5d9ba995f28b3d
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\core\src\fmt/mod.rs:1094:21
     6:     0x7ff6d8d4576b - std::io::Write::write_fmt::hc7addd828eb73daa
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\io/mod.rs:1714:15
     7:     0x7ff6d8d500e3 - std::sys_common::backtrace::_print::he35ac4a387784684
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common/backtrace.rs:47:5
     8:     0x7ff6d8d500e3 - std::sys_common::backtrace::print::h7bad5d62728e1103
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common/backtrace.rs:34:9
     9:     0x7ff6d8d53486 - std::panicking::default_hook::{{closure}}::h5067abc855bf1048
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src/panicking.rs:270:22
    10:     0x7ff6d8d53121 - std::panicking::default_hook::h240f0a26d6ddd9d1
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src/panicking.rs:290:9
    11:     0x7ff6d8d53cfb - std::panicking::rust_panic_with_hook::hc9234f56aa852168
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src/panicking.rs:707:13
    12:     0x7ff6d8d53b45 - std::panicking::begin_panic_handler::{{closure}}::h114d28b6ceee4a61
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src/panicking.rs:599:13
    13:     0x7ff6d8d51129 - std::sys_common::backtrace::__rust_end_short_backtrace::h94a97ff2f3d9d2cb
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common/backtrace.rs:170:18
    14:     0x7ff6d8d53890 - rust_begin_unwind
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src/panicking.rs:595:5
    15:     0x7ff6d8dae5e5 - core::panicking::panic_fmt::h9985522d043fc5f1
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\core\src/panicking.rs:67:14
    16:     0x7ff6d84eda91 - embed_resource::windows_not_msvc::ResourceCompiler::compile_resource::h1b683e9ff9a0491c
    17:     0x7ff6d84ed0ad - embed_resource::compile_impl::hb0f10c058fed80e6
    18:     0x7ff6d84edd8b - embed_resource::compile::hb1c34bfd1f2595e3
    19:     0x7ff6d84f91a3 - tauri_winres::WindowsResource::compile::h526310598b85c08d
    20:     0x7ff6d82cf1f3 - tauri_build::try_build::h9b26c899b08d2464
    21:     0x7ff6d82cc741 - tauri_build::build::h4e3e4cb5f90da34d
    22:     0x7ff6d82b1579 - build_script_build::main::h04d9f1c748319cef
    23:     0x7ff6d82b1626 - core::ops::function::FnOnce::call_once::h8304bef344ab5fd4
    24:     0x7ff6d82b1649 - std::sys_common::backtrace::__rust_begin_short_backtrace::h68fac4eaf7fae9cd
    25:     0x7ff6d82b155c - std::rt::lang_start::{{closure}}::h76e5bba808e0a08f
    26:     0x7ff6d8d36876 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hb3bdf4346df38b91
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\core\src\ops/function.rs:284:13
    27:     0x7ff6d8d36876 - std::panicking::try::do_call::h61c61764c4bdad62
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src/panicking.rs:502:40
    28:     0x7ff6d8d36876 - std::panicking::try::hb496e09f23995746
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src/panicking.rs:466:19
    29:     0x7ff6d8d36876 - std::panic::catch_unwind::h271d61ca37e37ebc
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src/panic.rs:142:14
    30:     0x7ff6d8d36876 - std::rt::lang_start_internal::{{closure}}::hdc458e19b8f78341
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src/rt.rs:148:48
    31:     0x7ff6d8d36876 - std::panicking::try::do_call::h64787de3a0157676
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src/panicking.rs:502:40
    32:     0x7ff6d8d36876 - std::panicking::try::h0f2ebb1d72d71417
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src/panicking.rs:466:19
    33:     0x7ff6d8d36876 - std::panic::catch_unwind::h624df61e1023a756
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src/panic.rs:142:14
    34:     0x7ff6d8d36876 - std::rt::lang_start_internal::hcf82168a9de7e079
                                 at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src/rt.rs:148:20
    35:     0x7ff6d82b1537 - std::rt::lang_start::hbafe7a2d8ca7de2d
    36:     0x7ff6d82b15af - main
    37:     0x7ff6d82b1395 - __tmainCRTStartup
    38:     0x7ff6d82b14e6 - mainCRTStartup
    39:     0x7ffe13df257d - <unknown>
    40:     0x7ffe159caa58 - <unknown>
 ELIFECYCLE  Command failed with exit code 4294967295.
 ELIFECYCLE  Command failed with exit code 101.

Additional context

No response

AceyKubbo commented 11 months ago

face the same issue

FabianLars commented 11 months ago

So, i got this report from 3 people (unless one of you also talked with me about it on discord) and i tried to reproduce it on 10 machines in various states (fresh install to 5 years in use) and i can't reproduce it whatever i try.

To my understanding this can only realistically happen if rust compiles for/with the gnu toolchain since it's guarded with conditional compilation cfg flags that act according to the target env: https://github.com/nabijaczleweli/rust-embed-resource/blob/master/src/lib.rs#L131-L134

I don't know, please make sure your toolchain set to msvc rustup default stable-msvc and that there is nothing that overwrites the target (btw, you can get a list of installed targets via rustup show, to check if you have the gnu target installed), like via .cargo/config.toml configurations.

Btw, cross compiling from the msvc windows toolchain to the gnu one or the other way around are not supported by rust-embed-resource, so if you want to compile to the msvc target you have to use the msvc toolchain (officially supported), and if you want to compile for the gnu target you have to use the gnu toolchain (not supported but should work if your msys installation has binutils installed for the resource compiler).

bling-yshs commented 11 months ago

I encountered the same issue, which was due to using the GNU toolchain. I resolved it by switching to MSVC following these steps:

  1. Uninstall Rust and any existing Visual Studio on the computer, and delete the '.rustup' folder in the user directory.
  2. Restart the computer.
  3. Download 'Visual C++ Build Tools' from (https://visualstudio.microsoft.com/visual-cpp-build-tools/) and install it (select 'C++ Desktop Development').
  4. Restart the computer (recommended).
  5. Install Rust using 'rustup-init.exe' (choose 1 - Proceed with installation (default)).
  6. Restart the computer (recommended)."
thewh1teagle commented 9 months ago

@FabianLars What can I do if I have to use gnu rust compiler in msys2? After I added resources to my program tauri uses it with embed-resource and I receive the error

 --- stderr
  windres: preprocessing failed.
  thread 'main' panicked at C:/msys64/ucrt64/.cargo\registry\src\index.crates.io-6f17d22bba15001f\embed-resource-2.4.1\src\windows_not_msvc.rs:48:25:
  windres failed to compile "C:\msys64\home\User\vibe\target\release\build\vibe-desktop-fc91fca7c7de9867\out\resource.rc" into "C:\msys64\home\User\vibe\target\release\build\vibe-desktop-fc91fca7c7de9867\out/libresource.a" with exit code: 1

I have dependency which can compile on windows only with gnu compiler of rust in the project vibe

Btw, before adding this resources I made this script which worked for me. I'm wondering if it can help

https://github.com/nabijaczleweli/rust-embed-resource/issues/65

FabianLars commented 9 months ago

@thewh1teagle Can you open a new issue or discussion for this? Your error seems to be different. Also please include this file in that issue/discussion "C:\msys64\home\User\vibe\target\release\build\vibe-desktop-fc91fca7c7de9867\out\resource.rc" (the random string may change on each build so get it from the error message) p.s. i never tried the ucrt64 packages, only the mingw64 ones, so i can't give you a guarantee ucrt64 works 🤷

ngxuancam commented 8 months ago

I encountered the same issue, which was due to using the GNU toolchain. I resolved it by switching to MSVC following these steps:

  1. Uninstall Rust and any existing Visual Studio on the computer, and delete the '.rustup' folder in the user directory.
  2. Restart the computer.
  3. Download 'Visual C++ Build Tools' from (https://visualstudio.microsoft.com/visual-cpp-build-tools/) and install it (select 'C++ Desktop Development').
  4. Restart the computer (recommended).
  5. Install Rust using 'rustup-init.exe' (choose 1 - Proceed with installation (default)).
  6. Restart the computer (recommended)."

The issue was not resolved for me. T_T Note: I am using Windows 10

crwntec commented 4 months ago

In my case I had another version of rust installed via choco. I realized that upon looking into the .rustc_info.json file in the target directory, because under "stdout" it showed that it was using gnu instead of msvsc as the toolchain. So consider checking if you are using the wrong toolchain

sanbeiicecream commented 3 months ago

I found the solution from here(https://github.com/rust-lang/rust/issues/91146#issuecomment-1556081181

zuoyifeng commented 3 months ago

I found the solution from here(rust-lang/rust#91146 (comment)

Please! How to install it and how to solve it?

sanbeiicecream commented 3 months ago

I found the solution from here(rust-lang/rust#91146 (comment)我从这里找到了解决方案( rust-lang/rust#91146 (comment)

Please! How to install it and how to solve it?请!如何安装以及如何解决?

Download the UCRT runtime from here (https://winlibs.com/#download-release ), extract it, and add the bin directory to the environment variables. Remember to remove the environment variables for other C/C++ compilers first.

I'm not sure if this will be helpful for you, but after making these changes, I was able to successfully build the program.