Repository navigation
fix(macos): 运行 Node 脚本时补齐启动 PATH (#1455) - #1492
Merged
Merged
Conversation
从 Finder 启动的 Lithe 只继承 launchd 的最小 PATH,pnpm/npm/yarn/tsx 的 #!/usr/bin/env node 找不到解释器,运行 package.json 脚本直接报 env: node: No such file or directory。 - RunLaunchEnvironment:启动前把发现到的 node 目录和解析出的可执行文件目录 前置到子进程 PATH,按小写去重;项目内 node 与项目根目录不注入,避免仓库 文件劫持后续系统命令。 - RunExecutableResolver:.toolchain 与 .command 共用同一条环境组合路径, 覆盖主进程和预启动步骤。 - RunLaunchEnvironmentTests:6 个用例覆盖补齐、项目内排除、wrapper 排除、 去重与顺序、缺失 PATH、resolver 实际接线。 - 新增 Agent Note 与平台特性矩阵 run-node-launch-path 记录。
- 启动 PATH 改为追加:原有条目(含运行配置显式 PATH)保持优先级,自动发现
的 node 与启动器目录追加在后;Finder 启动时 PATH 本就没有 node,追加同样生效。
- 新增「显式 PATH 保持优先级」与 .toolchain("project-node") 接线测试,共 8 例。
- 修正 Agent Note 与特性矩阵中「两端都排除项目目录」「与 Windows 一致」的不准确
表述,补充 fnm multishell 等发现范围限制与 Windows 排序差异。
Lithe Review结论: ❓ 审查未完成 任务: 347 审查状态:已由服务器取消 可以重新评论 |
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.
关联 Issue
Fixes #1455
问题
从 Finder / Dock 启动的 Lithe 继承 launchd 的最小
PATH(/usr/bin:/bin:/usr/sbin:/sbin)。Lithe 通过 Homebrew、fnm、nvm 探测能找到pnpm,但pnpm这类启动器用#!/usr/bin/env node查找解释器,子进程按自己的PATH找不到node,于是点运行后立刻报env: node: No such file or directory。代码链路:
MacRuntimeLocator.environment()返回ProcessInfo.processInfo.environment→ProjectRuntimeService.processEnvironment(overrides:)只叠加 override →RunExecutableResolver原样交给Process.start。发现结果从未进入子进程环境。改动点
RunLaunchEnvironment(macos/Sources/Lithe/Services/Java/RunLaunchEnvironment.swift)PATH;原有PATH顺序保留,按小写去重。source == .project的 node 不注入;可执行文件位于项目根内(mvnw/gradlew)时其目录也不注入,避免仓库文件劫持后续系统命令;与languageToolProcessEnvironment的既有规则一致。prepend_runtime_paths的启动环境语义对齐。RunExecutableResolver.resolve):.toolchain和.command共用同一条环境组合路径,主进程与预启动步骤都覆盖;终端、调试适配器、语言服务器不经过这里,行为不变。RunLaunchEnvironmentTests,6 例):最小 PATH 补齐、项目内 node 排除、项目 wrapper 排除、去重与顺序、缺失 PATH、resolver 对.command的实际接线。2026-10-25-run-launch-path-for-node-launchers.md)与特性矩阵run-node-launch-path行。验证
./.agents/skills/write-stable-tests/scripts/verify-test-stability.sh.../test-stability-macos.sh -- --filter RunLaunchEnvironmentTests.../test-stability-macos.sh -- --filter RunConfigurationIntegrationTests./scripts/verify-service-boundaries.sh./scripts/verify-agent-notes.sh./scripts/verify-platform-feature-matrix.sh./scripts/verify-platform-feature-matrix-change.sh origin/preview <snapshot>已知限制
./scripts/test-macos.sh并行运行时有大量 12s 级计时门失败(Editor documents、Search Everywhere、Agent service 等),抽样单独重跑均通过;未做基线对照,也未跑串行全量套件。pending。