Skip to content

Conversation

@sakina1303
Copy link

This PR fixes a panic that occurred during tauri android init when npm_execpath pointed to a path where file_stem() returned None—a situation that happens on some Windows setups and when using Bun.

Previously, the code called:

file_stem().unwrap().to_os_string()

If file_stem() returned None, the CLI crashed with an unwrap() panic.

What this PR changes-

This replaces the unsafe unwrap() with a safe fallback chain:

  1. file_stem()
  2. Or file_name()
  3. Or the original npm_execpath
    This ensures that the CLI never panics due to unexpected or non-standard npm/bun paths.

Why this is correct-

  • Handles Windows-specific cases where file_stem() legitimately returns None.
  • Makes the manager detection code fully panic-safe across all platforms.
  • Does not change higher-level behavior or command semantics.
  • Fixes the root cause of the crash without introducing breaking changes.

Verification-

  • Rebuilt tauri-cli
  • Symlinked the binary to node and set npm_execpath="/" to simulate the failing scenario
  • Confirmed the CLI no longer panics and proceeds normally

Fixes #14472

@sakina1303
Copy link
Author

@FabianLars Hi! Just wanted to check if this approach looks good to you, or if you’d like any adjustments.

@FabianLars
Copy link
Member

first of all i'd like us to investigate the user's issue a bit since this is not a common occurrence (we have many bun users). Depending on the root cause your PR may not even fix it for them.

Secondly, if we do need special handling for bun i'd prefer if it could look closer to the pnpm handling or the deno check rather than the extra stem check upfront.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📬Proposal

Development

Successfully merging this pull request may close these issues.

[bug] bun tauri android init fails on Windows

2 participants