Repository navigation
fix(desktop): Windows 上识别 PATH/JAVA_HOME 的 JDK,带空格路径的 .cmd 构建工具能正常启动 - #2040
Merged
Merged
Conversation
Fixes #2032 - 工具链:toolchains.candidates 传入 commandHomes(Core #67),JAVA_HOME 和 PATH 上的 安装以 host:shell 进入安装列表;新建项目的 JDK 选择器不再显示“未找到已安装的版本”。 设置页的 shell 行区分环境变量和 PATH 命令。PINNED_CORE_REVISION 升到 Core #67。 - buildprocess:Windows 上的 .cmd/.bat 由宿主构造 cmd.exe /d /c ""脚本" 参数" 命令行, 参数按 BatBadBut 修复后的规则转义。此前脚本路径和参数都带空格时,cmd 会去掉首尾引号, Maven 模型加载报 'C:\Program' 不是命令并以 exit 1 失败。 - 构建模型和依赖命令失败时,错误附带工具输出的最后 12 行(去掉终端控制符), 构建树的警告行悬停显示全文。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 task done
1lck
marked this pull request as ready for review
November 16, 2026 11:31
This was referenced Nov 16, 2026
17 of 20 tasks
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 / Linked issue
toolchains.candidates接受commandHomes,并列出 shell 来源的安装)PR 类型 / Type
改动说明 / What changes
背景 / Why
群里多次反馈 Windows 0.8.0 有两个问题,反馈者的 JDK 和 Maven 都装在
D:\Program Files\...,并且都在 PATH 上:在本机 Windows 虚拟机里两个问题都复现了。根因有三处:
toolchains.candidates只列出插件 discovery 扫描到的安装。Java 插件只为 macOS 写了扫描规则,JAVA_HOME和 PATH 上的java只参与“自动解析”,不会出现在选择器里。Windows 上 discovery 扫描结果为空,选择器就是空的。os/exec启动.cmd时,Windows 隐式执行cmd.exe /c <命令行>。如果脚本路径带空格(...\Program Files\...\mvn.cmd),后面的参数里也带引号,整行就会有两个以上的引号,cmd 会去掉首尾引号,最后报'D:\Program' 不是内部或外部命令,退出码为 1。改动 / Changes
工具链:把 shell 来源的 JDK 列为候选(依赖 Core #67)
desktop/internal/core/toolchain.goToolchainCandidatesRequest新增CommandHomes。ToolchainShellCandidate新增Command字段,Variable改为omitempty。desktop/internal/toolchain/load.go:调用candidates时,把已经解析出来的 PATH 命令 home(commandHomes)一起传过去。这样JAVA_HOME和 PATH 上java所在的安装会以host:shell进入选择器。同一个 home 已被扫描到时只列一次,保留扫描结果。desktop/internal/settingswindow/toolchains_view.go:设置页的 shell 来源行,没有环境变量时显示命令名(例如java)。scripts/desktop/build-desktop-core.sh:PINNED_CORE_REVISION升到16d17b19922ba636db506d28bdedd13ed88bed47(Core lithe 0.2.0 #67 分支上的提交)。buildprocess:Windows 上由宿主拼接
.cmd/.bat的命令行desktop/internal/buildprocess/batch.go,按 Rust std 修复 BatBadBut(CVE-2024-24576)之后的规则拼接命令行:cmd.exe /e:ON /v:OFF /d /c ""脚本" 参数…"。"写成"",引号前的反斜杠加倍。%前面插入%%cd:~,,防止 cmd 展开变量。process_windows.go:configure遇到批处理文件时,把Path换成系统目录下的cmd.exe,SysProcAttr.CmdLine设为拼好的命令行。configure改为返回 error。拼接失败时不启动进程,沿用原来关闭管道的路径(process.go、process_unix.go跟着调整签名)。构建失败时显示工具输出
desktop/internal/workbench/build.go、build_dependencies.go:构建模型和依赖命令失败时,错误后面附上工具输出的最后 12 行,每行最多 400 字节。附加前去掉终端控制序列,并把非法 UTF-8 替换掉。启动失败(buildLaunchError)不附加输出。build.go的状态栏只显示第一行。build_tree.go、build_tree_view.go:构建树里的失败行只显示第一行,悬停显示全文。功能矩阵
plugin-injected-toolchains.json、build-system-plugins.json:在 notes 里补充 [Bug] 无法识别Temurin JDK #2032 的说明,并加上证据路径。状态保持 partial/pending,因为完整 Windows 客户端的界面验收还没做。不在本 PR 范围内 / Out of scope
PINNED_CORE_REVISION暂时固定在 Core lithe 0.2.0 #67 分支的16d17b1(基于 Core main957a349,只多了 lithe 0.2.0 #67),做法同 [Feature] Git 控制台按类别省略内部查询并调整显示方式:设置页 13 个开关,初始状态与 IntelliJ IDEA 一致 #2025 / fix(desktop): Core 固定到 main 957a349,#64 合入后换掉分支 commit #2034。现在不能直接换成 Core main:lithe 0.2.0 #67 之前已经合入的 Core fix: resolve Swift 6.2 pointer modifier isolation #66 删除了editor.lineCommentToken,桌面端的配套改动在 fix(editor): 行注释符号改由语言注册表提供,插件声明的 lineComment 生效 (#1856) #2036,还没合入。fix(editor): 行注释符号改由语言注册表提供,插件声明的 lineComment 生效 (#1856) #2036 合入时会把固定版本升到 Core main,那个 commit 已经包含 lithe 0.2.0 #67,到时就替换掉本 PR 的分支 commit。类型专属:fix
复现与根因
C:\Program Files\...),并加入 PATH,同时设置JAVA_HOME。JAVA_HOME指向的 JDK。mvn.cmd,得到'C:\Program' 不是内部或外部命令。期望 Maven 正常运行并加载构建模型。0faecba49,Viva 迁移)引入。buildprocess在 Windows 上直接交给os/exec启动.cmd。检查项
desktop/internal/buildprocess/batch_windows_test.goTestBatchFileUnderASpacedDirectoryReceivesItsArguments:在 Windows 虚拟机上用修复前的代码运行,失败输出是'...\Program' 不是内部或外部命令;修复后通过。用例还覆盖了%VAR%展开和&注入,确认参数原样传到脚本,注入的命令没有执行。desktop/internal/toolchain/toolchain_test.goTestShellHomesAreInstallationsWithoutADiscoveryScan:去掉CommandHomes后测试失败(安装列表为空),加回后通过。desktop/internal/workbench/build_command_output_test.goTestBuildCommandFailureCarriesTheToolsExplanation:去掉withBuildOutput后测试失败(错误里只有exit status 1),加回后通过。toolchain_candidates_offer_shell_homes_that_no_discovery_scan_covers:修复前请求返回invalidParams,修复后通过。mvn.cmd跑的 probe。configure只有process.go一处调用。ToolchainShellCandidate.Variable只有设置页一处读取。toolchains.candidates只有toolchain/load.go一处调用。exit status 1。.agents/notes/implemented/bug-fix/记录:批处理拼接规则写在batch.go的注释和测试里,回归测试会防止复发,不需要另写 Note。范围检查 / Scope checks
功能矩阵 / Feature matrix
plugin-injected-toolchains.json、build-system-plugins.json。Windows 一侧补了batch_windows_test.go证据,验证状态保持pending,因为完整客户端的界面验收还没做。verify-platform-feature-matrix.sh(validated 194 platform capabilities)和verify-platform-feature-matrix-change.sh origin/main HEAD(passed)。.artifacts/下生成的矩阵视图。插件归属 / Plugin ownership
develop-lithe第三节的零依赖自查命令,结果为空。runtime.plugin.jsonfixture、fictional-vm),没有使用真实插件 ID。shared/i18n/。Java 插件的扫描规则在插件仓库的 PR feat(database): add integrated database workspace #17 里。commandHomes是 Core 的可选输入,插件清单格式没有变。UI 验证 / UI evidence
统一日志系统 / Structured logging
界面文案 / i18n
ModelFailed词条,附上的工具输出属于上游诊断,不翻译。node scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --check,都通过。逻辑归属 / Logic placement
commandHomes传给 Core。buildprocess。截取输出末尾属于界面呈现。.cmd/.bat扩展名,和 Maven 无关。性能与内存 / Performance and memory
设置 / Settings
插件契约 / Plugin contract
shared/plugins/contract/v1/)没有改动。Core lithe 0.2.0 #67 改的是 Core 自己的 RPCtoolchains.candidates,已更新rust/contracts/rust-core-api.md。PINNED_CORE_REVISION已升到包含该改动的 Core commit(Core lithe 0.2.0 #67 分支上的提交,Core 合入后再更新)。发行包与资源 / Bundle and resources
N/A:没有新增运行时资源,也没有新增下载、解压或缓存步骤。
无用代码与重构 / Dead code and refactoring
验证 / Verification
scripts/desktop/desktop-go.sh test ./...(完整套件)localshell有两个 PTY 用例在满负载下失败,单独重跑通过,和本次改动无关desktop-go.sh test -race(buildprocess、toolchain和workbench中的相关用例)buildprocess测试程序,在虚拟机里运行TestBatchFileUnderASpacedDirectory…中失败buildprocess的 probe 启动C:\Program Files\...\mvn.cmd加载构建模型exit status 1,模型文件没有写出;修复后 Maven 成功,写出 9746 字节的模型文件cargo test -p lithe-core --lib、clippy、注释检查node scripts/i18n/verify-app-language-localization.mjs、generate-i18n.mjs --checkverify-platform-feature-matrix.sh、verify-platform-feature-matrix-change.sh origin/main HEADdesktop-go.sh build ./cmd/lithe(GOARCH=amd64,MinGW-w64 GCC,链接的 Core 为16d17b1)C:\Program Files\Lithe Repro Tools\(不在任何插件的扫描规则里),只加入用户 PATH,不设JAVA_HOME;从 Lithe Store 安装现有的 Java Support 2.0.0(不含 lithe-plugin-java#17)和 Maven 1.0.021.0.12.1 C:/Program Files/Lithe Repro Tools/jdk-21.0.12.1+1;修复前是“未找到已安装的版本”compile结果为 BUILD SUCCESS;修复前是“构建模型加载失败:exit status 1”java%LOCALAPPDATA%和%APPDATA%下的Lithe Desktop、测试项目、编译目录、测试用 JDK/Maven,恢复用户 PATH,然后关机未能执行的检查和原因:
JAVA_HOME”的情况由 Core 和宿主的单元测试覆盖。提交前确认 / Final checks
main(cad565600)创建,目标分支为main。.artifacts/,没有提交。🤖 Generated with Claude Code