Skip to content

[bug] bun tauri android init fails on Windows #14472

@junovell

Description

@junovell

Describe the bug

Initializing a new android project on Windows using Bun fails, but it works as expected when using pnpm.

Reproduction

Must have android prerequisites and Bun installed.

ps> bun create tauri-app
ps> cd tauri-app && bun install
ps> bun tauri android init # fails, see stack trace below
ps> pnpm tauri android init # generates android files in `src-tauri/gen`

Full tauri info output

$ tauri info
 
[✔] Environment
    - OS: Windows 10.0.19045 x86_64 (X64)
    ✔ WebView2: 142.0.3595.80
    ✔ MSVC: Visual Studio Build Tools 2022
    ✔ rustc: 1.91.0 (f8297e351 2025-10-28)
    ✔ cargo: 1.91.0 (ea2d97820 2025-10-10)
    ✔ rustup: 1.28.2 (e4f3ad6f8 2025-04-28)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - pnpm: 10.22.0
    - bun: 1.3.2
 
[-] Packages
    - tauri 🦀: 2
    - tauri-build 🦀: No version detected
    - wry 🦀: No version detected
    - tao 🦀: No version detected
    - @tauri-apps/api  ⱼₛ: not installed!
    - @tauri-apps/cli  ⱼₛ: 2.9.4
 
[-] Plugins
    - tauri-plugin-opener 🦀: 2
    - @tauri-apps/plugin-opener  ⱼₛ: not installed!
       Error Failed to parse version `2` for crate `tauri`
       Error Failed to parse version `2` for crate `tauri-plugin-opener`
 
[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../build
    - devUrl: http://localhost:1420/
    - framework: Svelte
    - bundler: Vite

Stack trace

$ tauri android init
 
thread '<unnamed>' (4564) panicked at crates\tauri-cli\src\mobile\init.rs:87:16:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7ffcfb305791 - napi_register_module_v1
   1:     0x7ffcfaef0c0a - <unknown>
   2:     0x7ffcfb303fe4 - napi_register_module_v1
   3:     0x7ffcfb3055d4 - napi_register_module_v1
   4:     0x7ffcfb303c1c - napi_register_module_v1
   5:     0x7ffcfb30a8c3 - napi_register_module_v1
   6:     0x7ffcfb30a84f - napi_register_module_v1
   7:     0x7ffcfb30a83e - napi_register_module_v1
   8:     0x7ffcfb7f47d1 - napi_register_module_v1
   9:     0x7ffcfb7f483d - napi_register_module_v1
  10:     0x7ffcfb7f47fe - napi_register_module_v1
  11:     0x7ffcfb5a43e7 - napi_register_module_v1
  12:     0x7ffcfb5982a6 - napi_register_module_v1
  13:     0x7ffcfae44fc4 - <unknown>
  14:     0x7ffcfae53845 - <unknown>
  15:     0x7ffcfb3184fd - napi_register_module_v1
  16:     0x7ffd212c7374 - BaseThreadInitThunk
  17:     0x7ffd2293cc91 - RtlUserThreadStart
error: script "tauri" exited with code 9

Additional context

The bug happens in this block of code, line 87:

if let Some(bin_stem) = bin_path.file_stem() {
let r = regex::Regex::new("(nodejs|node)\\-?([1-9]*)*$").unwrap();
if r.is_match(&bin_stem.to_string_lossy()) {
if var_os("PNPM_PACKAGE_NAME").is_some() {
return ("pnpm".into(), build_args);
} else if is_pnpm_dlx() {
return ("pnpm".into(), vec!["dlx", "@tauri-apps/cli"]);
} else if let Some(npm_execpath) = var_os("npm_execpath") {
let manager_stem = PathBuf::from(&npm_execpath)
.file_stem()
.unwrap()
.to_os_string();
let is_npm = manager_stem == "npm-cli";
let binary = if is_npm {
"npm".into()
} else if manager_stem == "npx-cli" {
"npx".into()
} else {
manager_stem
};

Which doesn't seem to check for bun. Although, weirdly, on Linux this bug doesn't happen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions