From 25e37d6ddc7126abd4462cc38c815c6f35f4321c Mon Sep 17 00:00:00 2001 From: j4rviscmd Date: Sun, 10 May 2026 20:27:49 +0900 Subject: [PATCH] fix: strip UNC path prefix from resource_dir extensions path for Bun compatibility On Windows, Tauri's resource_dir() may return paths with the \\\\?\\ extended-length prefix. This prefix breaks Bun's require() in the Extension Host, preventing built-in extensions (git-base, github-authentication) from activating. Apply dunce::canonicalize() to all three resource directory fallback paths, consistent with the existing CWD-based path resolution. --- src-tauri/src/commands/extensions.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/commands/extensions.rs b/src-tauri/src/commands/extensions.rs index ed6b4fe7..96026dd1 100644 --- a/src-tauri/src/commands/extensions.rs +++ b/src-tauri/src/commands/extensions.rs @@ -84,21 +84,25 @@ fn resolve_extensions_dir(app_handle: &tauri::AppHandle) -> Option { // Fall back to resource directory for built apps. // Tauri maps `../.build/extensions` (from bundle.resources) to `_up_/.build/extensions`. + // + // On Windows, `resource_dir()` may return a path with the `\\?\` extended-length + // prefix. This prefix breaks Bun's `require()` in the Extension Host, so we + // canonicalize with `dunce` to strip it — consistent with the CWD-based paths above. if let Ok(rd) = app_handle.path().resource_dir() { // Primary: packaged extensions in .build/extensions let packaged = rd.join("_up_/.build/extensions"); if packaged.is_dir() { - return Some(packaged); + return Some(dunce::canonicalize(&packaged).unwrap_or(packaged)); } // Legacy: direct extensions path (from older bundle.resources config) let up_dir = rd.join("_up_/extensions"); if up_dir.is_dir() { - return Some(up_dir); + return Some(dunce::canonicalize(&up_dir).unwrap_or(up_dir)); } // Also check direct path in case bundled differently let direct = rd.join("extensions"); if direct.is_dir() { - return Some(direct); + return Some(dunce::canonicalize(&direct).unwrap_or(direct)); } }