Skip to content

fix(toolchain): 工具链候选列出 JAVA_HOME 和 PATH 上的安装 - #67

Merged
1lck merged 2 commits into
mainfrom
fix/toolchain-candidates-command-homes
Nov 16, 2026
Merged

1lck merged 2 commits into
mainfrom
fix/toolchain-candidates-command-homes

Conversation

@1lck

@1lck 1lck commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

关联 Issue:1lck/Lithe-IDEA#2032(Windows 上新建项目找不到 Temurin JDK)

问题

toolchains.candidates 的 installations 只包含插件 provider 报告的安装和 discovery 扫描结果。插件没有为当前平台声明扫描目录时,只通过 JAVA_HOME 或 PATH 能找到的工具不在列表里:

  • Java 插件只给 macOS 声明了扫描目录,所以 Windows 和 Linux 上列表永远为空。
  • 新建项目的 JDK 选择器显示“未找到已安装的版本。此项必填。”,设置页也选不中这个 JDK。
  • 但运行时解析(toolchains.resolve 的 environment/command 层)能找到并使用同一个 JDK,界面和实际行为不一致。

已在 Windows 11 虚拟机上用 Lithe 0.8.0 正式版复现:JDK 在 C:\Program Files\Java\Temurin\jdk-17.0.21+9,配置在 PATH 上,JAVA_HOME 设与不设结果相同。

改动

  • candidates 新增可选输入 commandHomes。字段形状与 resolve 已有的同名输入相同,由宿主报告 PATH 上找到的命令所在的 home。
  • shell 行在原有环境变量行之外,新增 PATH 命令行(带 command 字段,没有 variable)。
  • 检查通过的 shell home 以 provider host:shell 并入 installations,按规范化 home 去重(Windows 不区分大小写)。同一个 home 已被扫描或 provider 报告时,保留原来的归属。
  • selected(自动层的选择)、skipped 和 conflicts 不变:shell home 只作为可选项,不参与自动层的选择。
  • 更新 rust/contracts/rust-core-api.md 中 toolchains.candidates 的说明。

消费者:Lithe-IDEA 桌面端的工具链加载(设置页、新建项目、运行配置编辑器),会在对应 PR 里传入 commandHomes,并升级 PINNED_CORE_REVISION。仓库内其他调用方只有 dispatcher 和测试。新字段是可选的,旧宿主不传时行为不变。

验证

  • 新增回归测试 toolchain_candidates_offer_shell_homes_that_no_discovery_scan_covers,覆盖 JAVA_HOME 和 PATH 列出、同一 home 去重、扫描归属优先、版本不满足时不列出、非法 commandHomes 被拒。修复前该测试失败,返回 plugin.toolchain.invalidParams;修复后通过。
  • cargo test -p lithe-core --lib:822 passed。cargo test -p lithe-toolchain:通过。
  • cargo clippy -p lithe-toolchain -p lithe-core --all-targets -- -D warnings:通过。
  • scripts/rust-core/verify-rust-core-comments.sh toolchain:通过。
  • 未在本地运行 x86_64-pc-windows-msvc 目标的 clippy(本机没装该目标)。改动不含平台分支,交给 CI。

🤖 Generated with Claude Code

`toolchains.candidates` 的 installations 只包含插件 provider 报告的安装和
discovery 扫描结果。插件没有为某个平台声明扫描目录时(Java 插件在 Windows 和
Linux 上就是这样),只配了 JAVA_HOME 或 PATH 的 JDK 不会出现在列表里。
新建项目的选择器因此显示“未找到已安装的版本”,设置页也无法选中它,但运行时解析
(resolve 的 environment 和 command 层)其实能找到并使用它。

- candidates 接受可选的 commandHomes(与 resolve 相同的宿主输入)。shell 行在原有
  环境变量行之外,新增 PATH 命令行(带 command 字段)。
- 检查通过的 shell home 以 provider host:shell 并入 installations,按规范化 home
  去重;同一个 home 已被扫描或 provider 报告时,保留原来的归属。
- selected(自动层的选择)不变:shell home 只是可选项,不参与自动层的选择。

Refs 1lck/Lithe-IDEA#2032

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@1lck
1lck marked this pull request as ready for review November 16, 2026 11:27
@1lck
1lck merged commit 5a8d786 into main Nov 16, 2026
10 of 14 checks passed
@1lck
1lck deleted the fix/toolchain-candidates-command-homes branch November 16, 2026 12:31
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.

1 participant