Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

Merge remote-tracking branch 'origin/main' into fix/issue-182-plugin-spawn-env

hairyf2f8b01dcd16e
diff --cc src-tauri/src/service/plugin/install.rs
index 8b849940,aa291292..521e8a90
--- a/src-tauri/src/service/plugin/install.rs
+++ b/src-tauri/src/service/plugin/install.rs
@@@ -814,21 -793,6 +814,23 @@@ fn pnpm_major_version_at_with_node(pnpm
stdout.split('.').next()?.trim().parse::<u32>().ok()
}
+/// 构建 pnpm 探测专用 PATH:用户 pnpm 所在目录和选定 Node 目录前置,其余环境保留。
+fn pnpm_probe_path(pnpm: &Path, node: Option<&Path>) -> Option<OsString> {
+ let mut paths = Vec::new();
- if let Some(parent) = pnpm.parent() {
++ // 选定 Node 必须位于 pnpm shim 目录之前:corepack 目录可能残留另一份 node,
++ // bare `node` 应与桌面端预检和后续插件命令使用同一运行时。
++ if let Some(parent) = node.and_then(Path::parent) {
+ paths.push(parent.to_path_buf());
+ }
- if let Some(parent) = node.and_then(Path::parent) {
++ if let Some(parent) = pnpm.parent() {
+ paths.push(parent.to_path_buf());
+ }
+ paths.extend(std::env::split_paths(
+ &std::env::var_os("PATH").unwrap_or_default(),
+ ));
+ std::env::join_paths(paths).ok()
+}
+
/// 档案 `node_modules` 使用的 pnpm store 主版本(`<profile>/node_modules/.modules.yaml`
/// 的 `storeDir` 路径段,如 `...\store\v10` → 10)。
///
@@@ -1355,12 -1333,16 +1371,18 @@@ pub(crate) fn harness_prefer_bundled_pn
#[cfg(test)]
mod tests {
- use std::path::PathBuf;
- use super::{append_command_output, apply_allow_build_keys, collapse_allow_builds_duplicates, dep_path_to_name, extract_allow_line_key, extract_only_builds_git_name, git_transport_hint, normalize_git_spec, parse_allowlist_keys, parse_store_major_from_modules_yaml, preset_spec_for_install, shell_quote_spec, silent_install_failure_detail, PreinstallPluginInfo};
#[cfg(unix)]
use super::pnpm_major_version_at;
+ #[cfg(windows)]
+ use super::pnpm_major_version_at_with_node;
+ use super::{
+ append_command_output, apply_allow_build_keys, collapse_allow_builds_duplicates,
+ dep_path_to_name, extract_allow_line_key, extract_only_builds_git_name, git_transport_hint,
+ normalize_git_spec, parse_allowlist_keys, parse_store_major_from_modules_yaml,
+ preset_spec_for_install, shell_quote_spec, silent_install_failure_detail,
+ PreinstallPluginInfo,
+ };
+ use std::path::PathBuf;
#[cfg(unix)]
#[test]
@@@ -1392,35 -1372,6 +1412,39 @@@
let _ = std::fs::remove_dir_all(root);
}
++ /// 回归 Windows GUI 的陈旧 PATH:pnpm shim 必须解析到桌面端选定的 Node,
++ /// 即使 shim 同目录存在冲突的 node,且路径包含空格和 shell 元字符。
+ #[cfg(windows)]
+ #[test]
+ fn pnpm_major_version_probe_injects_selected_node_for_cmd_shim() {
+ use std::time::{SystemTime, UNIX_EPOCH};
+
+ let nonce = SystemTime::now()
+ .duration_since(UNIX_EPOCH)
+ .unwrap()
+ .as_nanos();
+ let root = std::env::temp_dir().join(format!(
+ "dsh pnpm cmd major {} {nonce}",
+ std::process::id()
+ ));
+ let pnpm_dir = root.join("pnpm & corepack");
+ let node_dir = root.join("selected node");
+ std::fs::create_dir_all(&pnpm_dir).unwrap();
+ std::fs::create_dir_all(&node_dir).unwrap();
+ let selected = pnpm_dir.join("pnpm.cmd");
+ let node = node_dir.join("node.cmd");
+ std::fs::write(&selected, "@echo off\r\nnode --version\r\n").unwrap();
++ // shim 目录里的冲突运行时若优先会输出 9;选定 Node 必须抢在它前面。
++ std::fs::write(pnpm_dir.join("node.cmd"), "@echo off\r\necho 9.0.0\r\n").unwrap();
+ std::fs::write(&node, "@echo off\r\necho 11.24.0\r\n").unwrap();
+
+ assert_eq!(
+ pnpm_major_version_at_with_node(&selected, Some(&node)),
+ Some(11)
+ );
+ let _ = std::fs::remove_dir_all(root);
+ }
+
/// 构造预设条目的测试助手(internal 由各用例显式指定)
fn preset(id: &str, spec: &str, internal: bool) -> PreinstallPluginInfo {
PreinstallPluginInfo {