Skip to content

fix(launcher): resolve Node for the npm diagnostic console - #1218

Merged
iruriQ merged 1 commit into
BytePioneer-AI:mainfrom
ChaceLyee2101:fix/npm-diagnostic-console-node
Nov 26, 2026
Merged

iruriQ merged 1 commit into
BytePioneer-AI:mainfrom
ChaceLyee2101:fix/npm-diagnostic-console-node

Conversation

@ChaceLyee2101

Copy link
Copy Markdown
Contributor

Summary

The native shell opens the diagnostic console by calling the Launcher directly. In an npm installation, the Launcher can receive no CODEXHOST_NPM_NODE_PATH or a path to a removed Node installation. npm packages have no bundled Node, so the Launcher can end up spawning a missing executable.

Keep the bundled or inherited absolute Node executable when available. For a confirmed npm distribution, resolve Node from PATH when those paths are unavailable. If Node cannot be found, report how to launch the console from a terminal with Node available.

Related issues

Refs #1200. The issue does not include the failed executable path. This PR covers the missing or stale npm Node path reproduced with an isolated install layout.

UI Demo

N/A (Launcher runtime selection).

Test plan

  • Reproduced CLI failure with a copied Launcher and an isolated npm layout containing no bundled Node.
  • cargo test --offline --locked -p codexhost-launcher --test cli passed all 12 tests on macOS. The regression covers absent and stale inherited Node paths and verifies that an installer missing its runtime still fails.
  • Windows cargo clippy --offline --locked -p codexhost-launcher --all-targets --target x86_64-pc-windows-msvc -- -D warnings, Cargo formatting, and git diff --check passed.
  • The Windows native-shell click path still needs verification on Windows.

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • 问题修复
    • 使用 npm 发行版时,即使未配置 Node 路径或原路径失效,控制台也可尝试从系统环境中查找 Node 并正常打开。
    • 如果系统环境中也找不到 Node,控制台会提示相应错误;其他发行版在缺少运行时的情况下仍会启动失败。

Launcher 现在会识别 npm 发行版。在该发行版的诊断控制台缺少有效 Node 路径时,Launcher 会从 PATH 查找 Node;其他发行版仍使用原有解析流程。

Changes: npm 发行版诊断控制台

Layer / File(s) Summary
检测 npm 发行版元数据
crates/launcher/src/console.rs
新增 uses_npm_distribution,仅在元数据有效、schemaVersion 为 1 且 distribution 为 npm 时返回 true。
解析控制台所需的 Node
crates/launcher/src/main.rs, crates/launcher/tests/cli.rs
当 npm 发行版的 Node 路径不是现存的绝对路径时,从 PATH 解析 Node;找不到时返回专用错误。测试覆盖未设置 Node 覆盖、覆盖路径失效和 installer 缺少运行时的情况。

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Launcher
  participant DistributionMetadata
  participant PATH
  participant ConsoleCommand
  Launcher->>DistributionMetadata: 检查控制台发行版
  DistributionMetadata-->>Launcher: 返回是否为 npm
  Launcher->>PATH: npm 且 Node 路径无效时解析 Node
  PATH-->>Launcher: 返回 Node 路径或未找到
  Launcher->>ConsoleCommand: 传入解析后的 Node
Loading

Possibly related issues

  • Issue 1200 报告从 native-shell 打开诊断控制台时出现 “系统找不到指定的路径。 (os error 3)”。本 PR 调整了 npm 发行版的 Node 路径解析;是否解决该报告仍需通过 Windows native-shell 验证。

Possibly related PRs

  • BytePioneer-AI/codex-host#593:该 PR 修改 macOS Launcher 的 Node 选择规则;两项变更都涉及内置或继承的 Node 路径及 npm 入口的 Node 选择。

Suggested reviewers: bwndlct, bytepioneer-ai, ump45nose

Merge Risk: Minimal · up to e7047

The change lets the npm diagnostic console find Node on PATH when no bundled Node is available, and shows a clear message if Node is missing. No concrete merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题 "fix(launcher): resolve Node for the npm diagnostic console" 与变更集主要内容一致。变更新增了 npm 发行版判断函数,并在 run_console_command 中从 PATH 解析 node,还新增了相应的 CLI 测试。标题简洁、具体,能说明主要修改点。
Description check Passed 描述说明了问题原因(原生外壳直接调用 Launcher,npm 安装中 CODEXHOST_NPM_NODE_PATH 缺失或指向已删除的 Node),并说明了修复方式(优先使用内置或继承的绝对路径,npm 发行版时从 PATH 解析,找不到时给出提示)。描述还包含测试计划与未验证的 Windows 点击路径。与变更集高度相关。
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
Fix failing CI checks

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 466d54c and e7047c4.

Files selected for processing: 3

  • crates/launcher/src/console.rs
  • crates/launcher/src/main.rs
  • crates/launcher/tests/cli.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Recent review details

Context from checks skipped due to timeout: 8

  • GitHub Check: CodeRabbit
  • GitHub Check: Static checks
  • GitHub Check: Web Host tests
  • GitHub Check: Check Linux ARM64
  • GitHub Check: Check ubuntu-22.04
  • GitHub Check: Check windows-latest
  • GitHub Check: Check macos-26
  • GitHub Check: Vitest
Additional context used

Code guidelines: 2

CLAUDE.md — auto-discovered
AGENTS.md — auto-discovered
Path-based instructions: 1

Source excerpt: Rust owns native launch, process management, update installation, and platform integration.

CodeRabbit inference engine (CLAUDE.md)

Files:

  • crates/launcher/src/console.rs
  • crates/launcher/src/main.rs
  • crates/launcher/tests/cli.rs
Additional comments: 1

crates/launcher/src/main.rs: 1

1693-1695: Functional Correctness

评论提出的问题已有源码答案:Windows 原生 shell 的诊断控制台点击入口经过 run_console_command,并使用 PR 中新增的 Node 解析逻辑。点击处理器不直接调用 console_command_for,因此不存在绕过新回退的独立启动路径。该疑点不成立,不需要修改。

@iruriQ
iruriQ merged commit 5fd9f66 into BytePioneer-AI:main Nov 26, 2026
7 of 8 checks passed
@iruriQ

iruriQ commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

感谢修复!仅对确认的 npm 发行版在内置/继承 Node 缺失时回退到 PATH,真实子进程单测覆盖完整,已核实 Windows CI 失败为无关 web-server 用例波动,现已合并。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants