DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
fix(workflow): strip \\\\?\\ prefix from DSH_NODE to fix pnpm shim on Windows (#198)
PanXmad16a7965062b8
diff --git a/src-tauri/src/service/cli/shim.rs b/src-tauri/src/service/cli/shim.rsindex 4c782d42..f2f87c67 100644--- a/src-tauri/src/service/cli/shim.rs+++ b/src-tauri/src/service/cli/shim.rs@@ -40,9 +40,13 @@ rem must not re-derive it from PATH (which can miss nodes the app found).rem Pure batch version check (for /f tokens + numeric compare), no powershellrem child: avoids console flashes when invoked without a console and skips therem per-call powershell startup cost.-if defined DSH_NODE (- if exist "%DSH_NODE%" goto :node_dsh-)+if not defined DSH_NODE goto :skip_dsh_node+set "NODE=%DSH_NODE%"+rem Windows canonical paths may carry a \\?\ verbatim prefix that cmd.exe+rem cannot launch directly; strip it before checking/using the path.+if "%NODE:~0,4%"=="\\?\" set "NODE=%NODE:~4%"+if exist "%NODE%" goto :launch+:skip_dsh_nodewhere node >nul 2>nulif errorlevel 1 goto :use_bundledfor /f "tokens=1,2 delims=v." %%a in ('node --version 2^>nul ^| findstr /b "v"') do set "NODE_MAJOR=%%a" & set "NODE_MINOR=%%b"@@ -71,8 +75,12 @@ const PS1_NODE_RESOLVE: &str = r#"# own child processes), then a version-compatible local node, then the# bundled runtime — see the CMD shim for why DSH_NODE wins first.$node = $null-if ($env:DSH_NODE -and (Test-Path -LiteralPath $env:DSH_NODE)) {+if ($env:DSH_NODE) {$node = $env:DSH_NODE+ # Windows canonical paths may carry a \\?\ verbatim prefix; strip it so+ # PowerShell/cmd can launch the path directly.+ if ($node.StartsWith('\\?\')) { $node = $node.Substring(4) }+ if (-not (Test-Path -LiteralPath $node)) { $node = $null }}if (-not $node) {$localNode = Get-Command node -ErrorAction SilentlyContinue@@ -1109,6 +1117,11 @@ mod tests {node_ok_at < node_dsh_label_at,"the :node_dsh label must come after :node_ok");+ // Windows canonical paths may carry a \\?\ verbatim prefix; the shim+ // must strip it before launching node (issue: pnpm --version fails+ // with "The system cannot find the path specified.").+ assert!(content.contains("NODE:~0,4%"));+ assert!(content.contains("NODE:~4%"));}#[test]@@ -1120,6 +1133,9 @@ mod tests {dsh_node_at < local_at,"DSH_NODE must be checked before the local node search");+ // Same verbatim-prefix stripping as the CMD shim.+ assert!(content.contains("StartsWith"));+ assert!(content.contains("Substring(4)"));}#[test]diff --git a/src-tauri/src/service/workflow/mod.rs b/src-tauri/src/service/workflow/mod.rsindex bda69e83..e7e6ef86 100644--- a/src-tauri/src/service/workflow/mod.rs+++ b/src-tauri/src/service/workflow/mod.rs@@ -839,9 +839,12 @@ pub async fn launch(app_handle: tauri::AppHandle) -> Result<(), String> {// 不一致(相对 PATH 条目 / junction / 子进程 PATH 布局差异),导致 pnpm// shim 报 "Node.js runtime not found"(issue #121,与 build_plugin_envs// 的注入保持一致)。先规范化为绝对路径:相对路径在子进程 CWD 下会解析- // 到错误位置;已存在(上面校验过)的 node 可安全 canonicalize。+ // 到错误位置;已存在(上面校验过)的 node 可安全 canonicalize。用+ // dunce::canonicalize 而不是 std::fs::canonicalize:后者在 Windows 上会+ // 返回 `\\?\` verbatim 前缀,cmd.exe 无法直接启动这种路径,导致 pnpm/dsh+ // shim 报 "The system cannot find the path specified."。let node_abs =- std::fs::canonicalize(&node_binary_path).unwrap_or_else(|_| node_binary_path.clone());+ dunce::canonicalize(&node_binary_path).unwrap_or_else(|_| node_binary_path.clone());envs.insert("DSH_NODE".to_string(),node_abs.to_string_lossy().into_owned(),