Skip to content

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

fix(plugin): 档案 store 主版本无匹配 pnpm 时重建安装元数据

hairyf344a3b96d64a
diff --git a/docs/AGENTS.desktop.md b/docs/AGENTS.desktop.md
index 545d073a..6058b18d 100644
--- a/docs/AGENTS.desktop.md
+++ b/docs/AGENTS.desktop.md
@@ -188,7 +188,7 @@ function ConfirmDialog(props: ConfirmDialogProps) {
## 6. 关键踩坑与修复避坑指南 (Pitfalls & Fixes)
* **原生模块 ABI 校验**:`prepare_active_runtime` 在启动前会运行 `NATIVE_PROBE_SCRIPT` 探测 ABI。若匹配失败,将自动补齐依赖或切至捆绑 Node 运行时。
-* **pnpm Store 绑定冲突**:为防止全局 `store-dir` 冲突导致插件安装失败,`build_plugin_envs` 会将档案记录的 `storeDir` 显式注入为 `npm_config_store_dir` 环境变量。
+* **pnpm Store 绑定冲突**:为防止全局 `store-dir` 冲突导致插件安装失败,`build_plugin_envs` 会将档案记录的 `storeDir` 显式注入为 `npm_config_store_dir` 环境变量。注入的是**去掉末尾 `v10`/`v11` 版本段的基目录**(`strip_store_version`)——pnpm 的 `getStorePath` 只在传入路径已以自身 `STORE_VERSION` 结尾时原样使用,否则追加自己的版本段,传完整路径会在主版本不一致时拼出 `store/v10/v11` 这种嵌套路径。若本机没有任何 store 主版本匹配的 pnpm(pnpm 10↔11 布局互不兼容),`ensure_pnpm` 会删除该档案的 `node_modules/.modules.yaml`(`reset_incompatible_modules_metadata`;pnpm 只在该文件存在时做 `checkCompatibility`),让当前 pnpm 重建安装树,而不是明知必败仍发车。报错可见性由 `install/diagnose.rs::store_mismatch_hint` 兜底:pnpm 正文里的两条 store 路径都不含 `ERR_`/`error`/`failed` 标记,会被 `pick_error_message` 全部丢掉。
* **YAML 补丁层错误 (Issue #525)**:损坏的 `cordis.patch.yml` 会被隔离为 `<Name>.broken-<Timestamp>`。若隔离/重命名失败,程序将直接中止并返回 `PATCH_LAYER_QUARANTINE_FAILED`,要求用户手动处理。
* **pnpm Workspace 多文档修复 (Issue #526)**:若 `pnpm-workspace.yaml` 被意外包含 `---` 多文档,解析器会自动尝试解析并合并为单文档落盘自愈(日志标记 `PROFILE_WORKSPACE_MULTI_DOCUMENT`)。
* **pnpm `link:` 回读失败兜底 (Issue #264)**:pnpm 建好内置插件目录链接后回读 `package.json` 可能**恒定**失败(libuv `UV_UNKNOWN` / 退出码 -4094,实时防护 / EDR / 云盘 / 重解析点过滤驱动所致),重试无法越过且会让启动永久卡在 Plugin installation 阶段;此时由桌面端自建链接并补齐清单(`service::plugin::internal::materialize`,日志标记 `INTERNAL_PLUGIN_OFFLINE_LINK_*`),**仅在诊断里的失败路径确属本轮待装入口时**才兜底(同一签名也可能来自用户自己的 `link:` 依赖,路径不可归因时只给排除项提示、绝不吞成成功)。该路径不写 `pnpm-lock.yaml` 的 importers 条目,由下一次 pnpm 操作补齐。
diff --git a/src-tauri/src/service/plugin/install/diagnose.rs b/src-tauri/src/service/plugin/install/diagnose.rs
index 4c9496cf..3c2ff5ff 100644
--- a/src-tauri/src/service/plugin/install/diagnose.rs
+++ b/src-tauri/src/service/plugin/install/diagnose.rs
@@ -1,6 +1,7 @@
//! 失败输出解析:识别网络错误(代理/DNS/连接/TLS)、git 传输层失败
-//! (HTTPS→SSH 回退提示),并从输出中挑选可展示的错误消息(ANSI 清洗、
-//! 命中错误标记的行优先、截断)。
+//! (HTTPS→SSH 回退提示)、pnpm store 布局不兼容(`ERR_PNPM_UNEXPECTED_STORE`
+//! 一族),并从输出中挑选可展示的错误消息(ANSI 清洗、命中错误标记的行优先、
+//! 截断)。
/// 给非空诊断文本加 `: ` 前缀,便于直接拼进错误消息(空文本返回空串)。
pub(super) fn diagnostic_suffix(detail: &str) -> String {
@@ -128,6 +129,60 @@ pub(super) fn git_transport_hint(output: &str) -> Option<&'static str> {
.map(|(_, hint)| *hint)
}
+/// pnpm `reportUnexpectedStore` / `reportUnexpectedVirtualStoreDir` 正文里分别给出
+/// 「档案记录的位置」与「当前解析出的位置」,路径用双引号包裹。
+const RECORDED_PATH_MARKERS: &[&str] = &[
+ "currently linked from the store at ",
+ "symlinked from the virtual store directory at ",
+];
+const CURRENT_PATH_MARKERS: &[&str] = &[
+ "now wants to use the store at ",
+ "now wants to use the virtual store at ",
+];
+
+/// 从 pnpm 失败输出里识别 store 布局不兼容(`ERR_PNPM_UNEXPECTED_STORE`、
+/// `ERR_PNPM_UNEXPECTED_VIRTUAL_STORE`、`ERR_PNPM_STORE_BREAKING_CHANGE`、
+/// `ERR_PNPM_MODULES_BREAKING_CHANGE`),返回带双方路径与处置办法的指引。
+///
+/// pnpm 只在正文里给出「档案记录的 store」与「当前 store」两条路径,而
+/// [`pick_error_message`] 的标记行过滤把它们全部丢掉(正文两行都不含
+/// `ERR_`/`error`/`failed` 标记),用户最终只看到
+/// `Unexpected store location (This error may happen if the node_modules was installed
+/// with a different major version of pnpm)` —— 插件装不上却看不到任何原因。这里直接从
+/// 原始输出把两条路径捞出来。
+pub(super) fn store_mismatch_hint(output: &str) -> Option<String> {
+ const CODES: &[&str] = &[
+ "err_pnpm_unexpected_store",
+ "err_pnpm_unexpected_virtual_store",
+ "err_pnpm_store_breaking_change",
+ "err_pnpm_modules_breaking_change",
+ ];
+ let lower = output.to_ascii_lowercase();
+ if !CODES.iter().any(|code| lower.contains(code)) {
+ return None;
+ }
+ Some(match (
+ quoted_after(output, RECORDED_PATH_MARKERS),
+ quoted_after(output, CURRENT_PATH_MARKERS),
+ ) {
+ (Some(recorded), Some(current)) => format!(
+ "The profile's node_modules was created by a different pnpm major version: it is linked from the store at \"{recorded}\", but the pnpm now in use resolves the store at \"{current}\". Install/update cannot succeed until those match — install the pnpm major version that created this profile, or delete the profile's node_modules directory and retry so pnpm rebuilds it with the current version."
+ ),
+ _ => "The profile's node_modules is not compatible with the pnpm version now in use (pnpm refused before installing). Install the pnpm major version that created this profile, or delete the profile's node_modules directory and retry so pnpm rebuilds it with the current version.".to_string(),
+ })
+}
+
+/// 取 `markers` 中最早出现的那一条之后紧跟的双引号路径。
+fn quoted_after(output: &str, markers: &[&str]) -> Option<String> {
+ let (index, marker) = markers
+ .iter()
+ .filter_map(|marker| output.find(marker).map(|index| (index, *marker)))
+ .min_by_key(|(index, _)| *index)?;
+ let rest = output[index + marker.len()..].strip_prefix('"')?;
+ let end = rest.find('"')?;
+ Some(rest[..end].to_string())
+}
+
#[cfg(test)]
mod tests {
use super::*;
@@ -173,4 +228,62 @@ mod tests {
let out = "[ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED] ...\nallowBuilds:\n node-pty: true\n";
assert!(git_transport_hint(out).is_none());
}
+
+ // ---- pnpm store 布局不兼容(ERR_PNPM_UNEXPECTED_STORE 一族)----
+
+ /// pnpm 的真实原始输出:档案由 pnpm 10 装好,当前 pnpm 11 解析出另一份 store。
+ const UNEXPECTED_STORE_OUTPUT: &str = r#"
+ ERR_PNPM_UNEXPECTED_STORE Unexpected store location
+
+The dependencies at "/Users/gao/.dsh/profiles/web/node_modules" are currently linked from the store at "/Users/gao/Library/pnpm/store/v10".
+
+pnpm now wants to use the store at "/Users/gao/Library/pnpm/store/v11" to link dependencies.
+
+If you want to use the new store location, reinstall your dependencies with "pnpm install".
+
+You may change the global store location by running "pnpm config set store-dir <dir> --global".
+(This error may happen if the node_modules was installed with a different major version of pnpm)
+"#;
+
+ #[test]
+ fn store_mismatch_hint_names_both_store_paths() {
+ let hint = store_mismatch_hint(UNEXPECTED_STORE_OUTPUT).expect("store hint");
+ assert!(hint.contains("/Users/gao/Library/pnpm/store/v10"));
+ assert!(hint.contains("/Users/gao/Library/pnpm/store/v11"));
+ assert!(hint.contains("node_modules"));
+ }
+
+ #[test]
+ fn store_mismatch_hint_covers_virtual_store_and_pathless_codes() {
+ let virtual_store = r#"
+ ERR_PNPM_UNEXPECTED_VIRTUAL_STORE Unexpected virtual store location
+
+The dependencies at "/p/node_modules" are currently symlinked from the virtual store directory at "/old/.pnpm".
+
+pnpm now wants to use the virtual store at "/new/.pnpm" to link dependencies from the store.
+"#;
+ let hint = store_mismatch_hint(virtual_store).expect("virtual store hint");
+ assert!(hint.contains("/old/.pnpm"));
+ assert!(hint.contains("/new/.pnpm"));
+
+ // 正文里没有双方路径(breaking change 一族)也要给指引,而不是退回裸标题
+ let pathless = r#"[ERR_PNPM_MODULES_BREAKING_CHANGE] The node_modules structure at "/p/node_modules" is not compatible with the current pnpm version. Run "pnpm install --force" to recreate node_modules."#;
+ assert!(store_mismatch_hint(pathless).is_some());
+ }
+
+ #[test]
+ fn store_mismatch_hint_none_for_other_failures() {
+ assert!(store_mismatch_hint("ERR_PNPM_NO_MATCHING_VERSION: no version").is_none());
+ assert!(store_mismatch_hint("").is_none());
+ }
+
+ #[test]
+ fn pick_error_message_drops_store_paths_which_is_why_the_hint_exists() {
+ // 回归说明:标记行过滤把两条 store 路径都丢掉(都不含 ERR_/error/failed),
+ // 用户只剩标题与末行括号说明 —— 必须由 store_mismatch_hint 兜住。
+ let picked = pick_error_message(UNEXPECTED_STORE_OUTPUT, None);
+ assert!(picked.contains("Unexpected store location"));
+ assert!(!picked.contains("store/v10"));
+ assert!(!picked.contains("store/v11"));
+ }
}
diff --git a/src-tauri/src/service/plugin/install/env.rs b/src-tauri/src/service/plugin/install/env.rs
index b4da5847..803a6654 100644
--- a/src-tauri/src/service/plugin/install/env.rs
+++ b/src-tauri/src/service/plugin/install/env.rs
@@ -67,9 +67,11 @@ pub(crate) fn build_plugin_envs(
// (典型场景:用户在另一个分区的工程里跑过 pnpm,pnpm 就把那份 store 写进了全局配置),
// 此时档案安装必然失败且无法自愈。这里显式下传档案记录的 store:
// pnpm 的优先级是 CLI > 环境变量 > 项目 .npmrc > 用户/全局配置,
- // 因此该值既压过用户配置,也必然等于 .modules.yaml 里的记录,子进程无从跑偏。
+ // 因此该值压过用户配置;传的是去掉版本段的基目录,由 pnpm 追加自身主版本的
+ // 版本段(主版本与档案一致时即等于 `.modules.yaml` 里的记录,见
+ // [`super::pnpm::profile_store_base_dir`])。
// 全新档案(没有 node_modules)不注入:让 pnpm 按用户配置自行决定并写回记录。
- if let Some(store_dir) = super::pnpm::profile_store_dir(app_handle) {
+ if let Some(store_dir) = super::pnpm::profile_store_base_dir(app_handle) {
log::info!("pinning plugin install pnpm store to the profile record: {store_dir}");
envs.insert("npm_config_store_dir".to_string(), store_dir);
}
diff --git a/src-tauri/src/service/plugin/install/mod.rs b/src-tauri/src/service/plugin/install/mod.rs
index 9b278dd4..62d12e9e 100644
--- a/src-tauri/src/service/plugin/install/mod.rs
+++ b/src-tauri/src/service/plugin/install/mod.rs
@@ -74,7 +74,10 @@ pub use single::{remove, update};
use allowlist::{add_allow_build_keys, parse_allowlist_keys};
use artifact::{ensure_plugin_entry_built, verify_installed_products};
-use diagnose::{diagnostic_suffix, git_transport_hint, network_error_hint, pick_error_message};
+use diagnose::{
+ diagnostic_suffix, git_transport_hint, network_error_hint, pick_error_message,
+ store_mismatch_hint,
+};
use pnpm::ensure_pnpm;
use spec::{bundled_dir_of, normalize_git_spec, preset_spec_for_install, shell_quote_spec};
@@ -282,11 +285,14 @@ async fn install_with_cancel(
let network_error = network_error_hint(&last_output).is_some()
|| (exit_code == 3 && last_output.trim().is_empty());
let hint = git_transport_hint(&last_output);
+ let store_hint = store_mismatch_hint(&last_output);
let network_hint = network_error.then_some(
"NETWORK_ERROR: plugin registry request failed; check network or proxy settings and retry.",
);
let message = if network_error {
network_hint.unwrap_or_default().to_string()
+ } else if let Some(store_hint) = store_hint.as_deref() {
+ store_hint.to_string()
} else {
pick_error_message(&last_output, hint)
};
@@ -320,6 +326,21 @@ async fn install_with_cancel(
"PREINSTALL_FAILED: dsh plugin exited with code {exit_code} ({hint})"
));
}
+ // pnpm 因档案 node_modules 与当前 pnpm 的 store 布局不匹配而拒绝安装:
+ // 报错正文里的两条 store 路径会被 pick_error_message 丢掉,这里补上可读
+ // 指引,避免用户只看到「插件安装失败」。
+ if let Some(store_hint) = store_hint {
+ log::warn!("pnpm store incompatibility detected during plugin install: {store_hint}");
+ let _ = window.emit(
+ PREINSTALL_LOG_EVENT,
+ PreinstallLogPayload {
+ line: format!("[pnpm] {store_hint}"),
+ },
+ );
+ return Err(format!(
+ "PREINSTALL_FAILED: dsh plugin exited with code {exit_code} ({store_hint})"
+ ));
+ }
let detail = pick_error_message(&last_output, None);
if !detail.is_empty() {
log::error!("dsh plugin install diagnostic: {detail}");
diff --git a/src-tauri/src/service/plugin/install/pnpm.rs b/src-tauri/src/service/plugin/install/pnpm.rs
index 8e3573d6..1f15c502 100644
--- a/src-tauri/src/service/plugin/install/pnpm.rs
+++ b/src-tauri/src/service/plugin/install/pnpm.rs
@@ -51,9 +51,23 @@ pub(super) async fn ensure_pnpm(
log::info!("Using bundled pnpm (major {store}) matching profile store");
return Ok(true);
}
+ // 本机没有该 store 主版本的 pnpm(捆绑版与用户版都不匹配):档案的安装
+ // 元数据已无法与将要使用的 pnpm 兼容,继续跑只会以
+ // `ERR_PNPM_UNEXPECTED_STORE` 失败。删掉元数据,让下面选出的 pnpm 以自身
+ // 主版本布局重建安装树,而不是明知必败仍发车。
log::warn!(
- "No pnpm matches profile store major {store} (user {user_major:?}), falling back to user pnpm"
+ "No pnpm matches profile store major {store} (user {user_major:?}), resetting profile modules metadata"
);
+ if reset_incompatible_modules_metadata(app_handle) {
+ let _ = window.emit(
+ PREINSTALL_LOG_EVENT,
+ PreinstallLogPayload {
+ line: format!(
+ "[pnpm] no pnpm matches this profile's store major {store}; rebuilt the profile modules metadata for the pnpm in use"
+ ),
+ },
+ );
+ }
}
// 2) store 未知(全新档案/未装过依赖)或无可匹配版本 → 用户 pnpm ≥ 10 优先
@@ -623,19 +637,71 @@ pub(crate) fn profile_store_major(app_handle: &AppHandle) -> Option<u32> {
parse_store_major_from_modules_yaml(&read_modules_yaml(app_handle)?)
}
-/// 档案 `node_modules/.modules.yaml` 记录的 pnpm store 目录(原样,含 `v10` 版本段)。
+/// 档案 `node_modules/.modules.yaml` 记录的 pnpm store 基目录(去掉 `v10` 版本段)。
///
/// 与 [`profile_store_major`] 同源,但给出整条路径:pnpm 只在「解析出的 store」与
/// `node_modules/.modules.yaml` 记录的一致时才继续安装,否则 `ERR_PNPM_UNEXPECTED_STORE`。
/// 用户的 pnpm 用户级/全局配置(或 `npm_config_store_dir` 环境变量)可能把 store 指到
/// 别处,而档案早已按自己那份 store 装好——此时任何 `dsh plugin` 安装/升级都会失败,
-/// 与插件本身无关。把这个值下传给子进程(见 [`super::env::build_plugin_envs`])即可
-/// 保证子进程用的必然是与档案一致的那份 store。
+/// 与插件本身无关。把这个基目录下传给子进程(见 [`super::env::build_plugin_envs`])即可
+/// 保证子进程落在与档案一致的那份 store 上。
+///
+/// 下传的必须是基目录而非记录原文(含版本段):版本段由 pnpm 按自身主版本追加,见
+/// [`strip_store_version`]。
+pub(crate) fn profile_store_base_dir(app_handle: &AppHandle) -> Option<String> {
+ let store_dir = parse_store_dir_from_modules_yaml(&read_modules_yaml(app_handle)?)?;
+ Some(strip_store_version(&store_dir))
+}
+
+/// 去掉 store 目录末尾的 pnpm 版本段(`...\store\v10` → `...\store`)。
///
-/// pnpm 对末尾的版本段是幂等的(传 `...\store\v10` 与传 `...\store` 解析结果相同),
-/// 因此这里原样返回、不做剥离。
-pub(crate) fn profile_store_dir(app_handle: &AppHandle) -> Option<String> {
- parse_store_dir_from_modules_yaml(&read_modules_yaml(app_handle)?)
+/// pnpm 计算实际 store 时只在「传入路径已以自身 `STORE_VERSION` 结尾」时原样使用,
+/// 否则追加自己的版本段(`getStorePath`)。下传带版本段的路径只在 pnpm 主版本与
+/// 档案一致时才等价:主版本不一致时会拼出不存在的嵌套路径(`store\v10\v11`),
+/// 与 `.modules.yaml` 的记录必然失配。去掉版本段后由 pnpm 自行补齐 —— 一致时结果
+/// 完全相同,不一致时也落在同一份 store 的兄弟目录,不会多出一个位置。末尾不是
+/// `v<数字>` 段(包含路径本身就是版本段名)时原样返回。
+fn strip_store_version(store_dir: &str) -> String {
+ let trimmed = store_dir.trim_end_matches(['\\', '/']);
+ let last = trimmed.rsplit(['\\', '/']).next().unwrap_or_default();
+ let keep = trimmed.len() - last.len();
+ let digits = last.strip_prefix('v').unwrap_or_default();
+ if keep == 0 || digits.is_empty() || !digits.bytes().all(|b| b.is_ascii_digit()) {
+ return store_dir.to_string();
+ }
+ trimmed[..keep].trim_end_matches(['\\', '/']).to_string()
+}
+
+/// 删除档案的 pnpm 安装元数据(`node_modules/.modules.yaml`),让 pnpm 以当前
+/// 主版本重建安装树;返回是否真的删掉了文件。
+///
+/// pnpm 只在 `.modules.yaml` 存在时做兼容性校验(`checkCompatibility`:先
+/// `layoutVersion`,再 `storeDir`、`virtualStoreDir`),而 `storeDir` 记的是解析后的
+/// **完整**路径(含 `v10`/`v11` 版本段)。档案由 pnpm 10 安装、本机只剩 pnpm 11
+/// 时,pnpm 11 解析出的 store 与记录必然不同,任何安装/升级都以
+/// `ERR_PNPM_UNEXPECTED_STORE` 失败 —— 档案本身健康,用户看到的却只是「插件安装
+/// 失败」。该文件是纯元数据,删掉后 pnpm 跳过校验、按当前 pnpm 的 store 布局重新
+/// 链接(与 `service::migrate` 处理 `ERR_PNPM_UNEXPECTED_VIRTUAL_STORE` 的做法一致)。
+pub(crate) fn reset_incompatible_modules_metadata(app_handle: &AppHandle) -> bool {
+ let modules_yaml = profile_dir(app_handle)
+ .join("node_modules")
+ .join(".modules.yaml");
+ if !modules_yaml.is_file() {
+ return false;
+ }
+ match std::fs::remove_file(&modules_yaml) {
+ Ok(()) => {
+ log::info!(
+ "reset incompatible pnpm modules metadata: {}",
+ modules_yaml.display()
+ );
+ true
+ }
+ Err(e) => {
+ log::warn!("reset {} failed: {e}", modules_yaml.display());
+ false
+ }
+ }
}
/// 读取档案的 `node_modules/.modules.yaml`;文件缺失(全新档案)返回 `None`。
@@ -962,7 +1028,7 @@ virtualStoreDir: node_modules/.pnpm
#[test]
fn store_dir_parsed_for_handoff_to_pnpm() {
- // 下传给 `npm_config_store_dir` 的必须是完整路径(含 v10 版本段,pnpm 对该段幂等)
+ // 解析必须保留记录原文(含 v10 版本段),由 strip_store_version 决定下传什么
let content = "\
hoistPattern:
- '*'
@@ -994,4 +1060,35 @@ virtualStoreDir: node_modules/.pnpm
None
);
}
+
+ #[test]
+ fn store_base_dir_strips_trailing_pnpm_version_segment() {
+ assert_eq!(
+ strip_store_version("C:\\Users\\test\\AppData\\Local\\pnpm\\store\\v10"),
+ "C:\\Users\\test\\AppData\\Local\\pnpm\\store"
+ );
+ assert_eq!(
+ strip_store_version("/home/test/.local/share/pnpm/store/v11"),
+ "/home/test/.local/share/pnpm/store"
+ );
+ // 含空格/以分隔符结尾的写法
+ assert_eq!(
+ strip_store_version("/Users/gao/Library/pnpm/store/v10/"),
+ "/Users/gao/Library/pnpm/store"
+ );
+ assert_eq!(strip_store_version("D:\\.pnpm-store\\v3"), "D:\\.pnpm-store");
+ }
+
+ #[test]
+ fn store_base_dir_keeps_paths_without_version_segment() {
+ // 末尾不是 v<数字>:原样返回,避免把用户自定的 store 目录名吃掉
+ assert_eq!(
+ strip_store_version("C:\\Users\\x\\pnpm\\store"),
+ "C:\\Users\\x\\pnpm\\store"
+ );
+ assert_eq!(strip_store_version("/mnt/pnpm-store-v10"), "/mnt/pnpm-store-v10");
+ assert_eq!(strip_store_version("/mnt/v-store"), "/mnt/v-store");
+ assert_eq!(strip_store_version("v10"), "v10");
+ assert_eq!(strip_store_version(""), "");
+ }
}
diff --git a/src-tauri/src/service/plugin/install/single.rs b/src-tauri/src/service/plugin/install/single.rs
index afc155b7..4164f9c0 100644
--- a/src-tauri/src/service/plugin/install/single.rs
+++ b/src-tauri/src/service/plugin/install/single.rs
@@ -16,7 +16,9 @@ use crate::service::workflow;
use super::artifact::{ensure_plugin_entry_built, installed_package_name};
use super::build_plugin_envs;
-use super::diagnose::{git_transport_hint, network_error_hint, pick_error_message};
+use super::diagnose::{
+ git_transport_hint, network_error_hint, pick_error_message, store_mismatch_hint,
+};
use super::errors;
use super::installed_name;
use super::is_actionable_plugin_ref;
@@ -318,9 +320,12 @@ async fn run_single_plugin_command(
log::error!("dsh plugin {action} failed for {id} with exit code {exit_code}");
let network_error =
network_error_hint(&output).is_some() || (exit_code == 3 && output.trim().is_empty());
+ let store_hint = store_mismatch_hint(&output);
let message = if network_error {
"NETWORK_ERROR: plugin registry request failed; check network or proxy settings and retry."
.to_string()
+ } else if let Some(store_hint) = store_hint.as_deref() {
+ store_hint.to_string()
} else {
pick_error_message(&output, git_transport_hint(&output))
};
@@ -330,6 +335,14 @@ async fn run_single_plugin_command(
if network_error {
return Err("NETWORK_ERROR: plugin registry request failed; check network or proxy settings and retry.".to_string());
}
+ // 与批量安装一致:把 pnpm 因 store 布局不匹配给出的两条路径补进错误里
+ if let Some(store_hint) = store_hint {
+ log::warn!("pnpm store incompatibility detected during plugin {action}: {store_hint}");
+ return Err(format!(
+ "PLUGIN_{}_FAILED: dsh plugin exited with code {exit_code} ({store_hint})",
+ action.to_uppercase()
+ ));
+ }
return Err(format!(
"PLUGIN_{}_FAILED: dsh plugin exited with code {exit_code}",
action.to_uppercase()