Repository navigation
fix(opencode): read PATH and PATHEXT case-insensitively so the plugin finds rtk on Windows - #4626
qwist1233-cpu wants to merge 2 commits into
Conversation
… finds rtk on Windows OpenCode's Bun runtime on Windows exposes the variable under its native `Path` key, so `process.env.PATH` was undefined, no directory was probed and the plugin disabled itself with "no rtk on OpenCode's PATH". Closes rtk-ai#4625
|
|
📊 Automated PR Analysis
SummaryFixes a bug where resolveRtkPath() in the OpenCode plugin read process.env.PATH/PATHEXT with exact casing, which fails under OpenCode's Bun runtime on Windows where these vars are exposed as Path/PathExt, causing the plugin to disable itself. Adds a case-insensitive envVar() helper and applies it to both lookups, along with a new unit test. Review Checklist
Linked issues: #4625 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
|
Thanks, this looks like the right fix for #4625. Before we can review and merge it, the CLA needs to be signed, the CLAassistant bot left the link above. |
|
I have read the CLA Document and I hereby sign the CLA |
|
recheck |
|
I have read the CLA Document and I hereby sign the CLA |
|
recheck |
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q9q9u6LVGiugiXESP56EQK Signed-off-by: qwist1233-cpu <qwist1233-cpu@users.noreply.github.com>
Summary
resolveRtkPath()looked upprocess.env.PATHandprocess.env.PATHEXTby exact key. On Windows the variables are stored asPath/PATHEXT, and inside OpenCode's Bun runtime that casing leaks through, soPATHcame back undefined, no directory was probed and the plugin disabled itself withno rtk on OpenCode's PATH(OpenCode plugin only reads process.env.PATH, not Path — self-disables on Windows/Bun #4625).envVar(env, name)helper that returns the exact key when present and otherwise the first key that matches case-insensitively (which is how Windows itself resolvesPathvsPATH), and uses it for both variables.Closes #4625
Test plan
node --test hooks/opencode/rtk.test.mjs— 11 pass (the existing 10 plus a newenvVartest that feeds a plain object withPath/PathExtkeys, since Node's ownprocess.envis case-insensitive on Windows and cannot stand in for Bun's).resolveRtkPath()under Bun 1.4.3 from PowerShell, whereObject.keys(process.env)reports["Path","PATHEXT"]; it resolves a fakertk.exeplaced onPath. Note that a standalone Bun 1.4.3 already resolvesprocess.env.PATHcase-insensitively, so this does not reproduce the failure on its own; the reporter's OpenCode-bundled runtime does (keys=["Path"],PATHlength 0). The change makes the lookup independent of that runtime behaviour either way.cargo fmt --all && cargo clippy --all-targets && cargo test— not run; no Rust code changes (the plugin is embedded viainclude_str!).