tauri-apps / tauri

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

[bug] Yarn Executable not found by BuildTask.kt on windows, when building Android with Yarn and Svelte #9961

Open kartonrad opened 3 weeks ago

kartonrad commented 3 weeks ago

Describe the bug

The android build fails with: A problem occurred starting process 'command 'yarn-1.22.22.cmd''

Reproduction

Install yarn using corepack:

corepack enable
corepack install yarn@1.22.22 # default version if no "packageManager" field is found in package.json

Or install yarn using npm

npm install yarn@1.22.22 --global

Both methods do not work as expected

Then run cargo create-tauri-app --beta Then yarn tauri android init Then yarn tauri android dev

The process will crash

Expected behavior

Tauri should set the packageManager field in package.json, then just run yarn --version and check if the version constraint was respected.

If not, it should print an error which tells the user to install yarn using corepack, which respects the packageManager field and will even install arbritrary yarn versions based on the field.

If the version check succeeds, it should just run 'yarn ...'

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.22631 X64
    ✔ WebView2: 125.0.2535.79
    ✔ MSVC:
        - Visual Studio Build Tools 2019
        - Visual Studio Community 2022
    ✔ rustc: 1.76.0 (07dca489a 2024-02-04)
    ✔ cargo: 1.76.0 (c84b36747 2024-01-18)
    ✔ rustup: 1.27.0 (bbb9276d2 2024-03-08)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 20.13.1
    - yarn: 1.22.22
    - npm: 10.5.2

[-] Packages
    - tauri [RUST]: 2.0.0-beta.22
    - tauri-build [RUST]: 2.0.0-beta.17
    - wry [RUST]: 0.40.1
    - tao [RUST]: 0.28.0
    - tauri-cli [RUST]: 2.0.0-beta.20
    - @tauri-apps/api [NPM]: 2.0.0-beta.13
    - @tauri-apps/cli [NPM]: 2.0.0-beta.20

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../build
    - devUrl: http://localhost:1420/
    - framework: Svelte
    - bundler: Vite
Done in 5.41s.

Stack trace

No response

Additional context

No response

kartonrad commented 3 weeks ago

As a workaround, edit BuildTask.kt, find the 'executable' variable, and change "yarn-1.22.22" to 'yarn'

The build will succeed ✨

Thank you Tauri Team for your amazing work coordinating this monstrous software stack 😮