Repository navigation
fix(mcp): 安装技能前解析 npx 真实路径并补全子进程 PATH - #449
Merged
Merged
Conversation
macOS 上从 Finder / Dock 启动的 GUI 进程只继承 `/usr/bin:/bin:/usr/sbin:/sbin`, 设置页「安装 Navop Skill」裸 spawn `npx` 直接得到 `No such file or directory (os error 2)`,同一条命令在终端里却能成功。npx 的 shebang 是 `#!/usr/bin/env node`,只把它解析成绝对路径仍会以 `env: node: No such file or directory` 失败,所以要把程序目录也补进子进程 PATH。 - process-util 新增 program 模块:`resolve_program` 按环境 PATH 加上系统/家目录 兜底目录(Homebrew、/usr/local、nvm/fnm/volta/asdf/bun/pnpm)解析并校验 可执行位,`build_command` 额外把程序目录前置到子进程 PATH,Windows 的 `.cmd`/`.bat` 走 `cmd /C` - 设置页安装技能改走 `process_util::build_command`,启动器缺失时给出可操作的 提示(新增 `skill_install_launcher_missing`) - MCP 运行时要求状态改为真实探测,不再无条件显示「已就绪」(新增 `runtime_requirements_missing`,就绪文案带上解析到的路径) - 持久化到 Codex / Claude 配置里的 `command` 仍是可移植的 `"npx"`,不改成绝对 路径(沿用 f821ed1 的取舍) - AGENTS.md 记录该类 GUI 进程 PATH 问题的触发信号与正确做法 验证:`cargo test -p process-util`(8 passed);`cargo test -p main`(697 passed);`cargo test -p main mcp_`(76 passed);`RUSTFLAGS="-D warnings" cargo check -p main`;`cargo clippy -p process-util --all-targets` 与 `cargo clippy -p main --all-targets`(改动文件无告警)。另外把 PATH 设成 `/usr/bin:/bin:/usr/sbin:/sbin` 做 GUI 等价验证:解析到 `/opt/homebrew/bin/npx`、子进程 PATH 带 `/opt/homebrew/bin`、`npx --version` 返回 11.19.0。
feigeCode
force-pushed
the
fix/mcp-skill-install-npx-path
branch
from
October 22, 2026 02:52
3786a64 to
ef699d1
Compare
feigeCode
added a commit
that referenced
this pull request
Oct 22, 2026
合入 dev 做整体联调(启动验证后再决定是否合 main)
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
现象
macOS 上从 Finder / Dock 启动 Navop,在设置页点「安装 Navop Skill」失败:
同一条命令在终端里(PATH 含
/opt/homebrew/bin)能正常返回{"ok":true,"result":{"path":"~/.agents/skills/navop"}}。根因
/usr/bin:/bin:/usr/sbin:/sbin(ps eww <pid>可证),npx一般只装在/opt/homebrew/bin,裸Command::new("npx")直接 ENOENT。npx解析成绝对路径还不够:它的 shebang 是#!/usr/bin/env node,子进程 PATH 仍缺/opt/homebrew/bin时env找不到 node(env -i PATH=/usr/bin:/bin /opt/homebrew/bin/npx --version→env: node: No such file or directory)。改动
crates/process-util新增program模块:resolve_program按环境 PATH 加上系统/家目录兜底目录(/opt/homebrew/bin、/usr/local/bin、nvm/fnm/volta/asdf/bun/pnpm 的 bin,版本号降序)解析并校验可执行位;build_command额外把程序目录前置到子进程 PATH;Windows 上.cmd/.bat走cmd /C。main/src/settings/mcp_skill_install.rs改走process_util::build_command,启动器缺失时给出可操作提示(新增skill_install_launcher_missing),不再把 io 错误原样抛给用户。main/src/settings/mcp_helper_install.rs的运行时要求状态改为真实探测(新增runtime_requirements_missing,就绪文案带上解析到的路径)。command仍是可移植的"npx",不改成绝对路径(沿用 f821ed1 的取舍)。AGENTS.md记录该类 GUI 进程 PATH 问题的触发信号与正确做法。验证
cargo test -p process-util→ 8 passedcargo test -p main→ 697 passed(含新增源码契约skill_install_resolves_the_launcher_before_spawning)cargo test -p main mcp_→ 76 passedRUSTFLAGS="-D warnings" cargo check -p main→ okcargo clippy -p process-util -p main --all-targets→ 改动文件无告警/usr/bin:/bin:/usr/sbin:/sbin后解析到/opt/homebrew/bin/npx,子进程 PATH 带/opt/homebrew/bin,npx --version返回 11.19.0未覆盖
Windows 上只有
.cmd/.bat走cmd /C这一支能编译通过,本机是 macOS,需 Windows 实机确认安装流程。