Skip to content

fix(opencode): read PATH and PATHEXT case-insensitively so the plugin finds rtk on Windows - #4626

Open
qwist1233-cpu wants to merge 2 commits into
rtk-ai:developfrom
qwist1233-cpu:fix/4625-opencode-windows-path-key
Open

qwist1233-cpu wants to merge 2 commits into
rtk-ai:developfrom
qwist1233-cpu:fix/4625-opencode-windows-path-key

Conversation

@qwist1233-cpu

Copy link
Copy Markdown

Summary

  • resolveRtkPath() looked up process.env.PATH and process.env.PATHEXT by exact key. On Windows the variables are stored as Path/PATHEXT, and inside OpenCode's Bun runtime that casing leaks through, so PATH came back undefined, no directory was probed and the plugin disabled itself with no rtk on OpenCode's PATH (OpenCode plugin only reads process.env.PATH, not Path — self-disables on Windows/Bun #4625).
  • Adds a small 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 resolves Path vs PATH), and uses it for both variables.

Closes #4625

Test plan

  • node --test hooks/opencode/rtk.test.mjs — 11 pass (the existing 10 plus a new envVar test that feeds a plain object with Path / PathExt keys, since Node's own process.env is case-insensitive on Windows and cannot stand in for Bun's).
  • Manual, Windows 11: ran the patched resolveRtkPath() under Bun 1.4.3 from PowerShell, where Object.keys(process.env) reports ["Path","PATHEXT"]; it resolves a fake rtk.exe placed on Path. Note that a standalone Bun 1.4.3 already resolves process.env.PATH case-insensitively, so this does not reproduce the failure on its own; the reporter's OpenCode-bundled runtime does (keys=["Path"], PATH length 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 via include_str!).

… 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
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added bug Something isn't working opencode windows labels Oct 17, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes 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

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4625


Analyzed automatically by wshm · This is an automated analysis, not a human review.

@pszymkowiak

Copy link
Copy Markdown
Collaborator

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.

@qwist1233-cpu

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@qwist1233-cpu

Copy link
Copy Markdown
Author

recheck

@qwist1233-cpu

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@KuSh KuSh added the needs-cla label Oct 31, 2026
@qwist1233-cpu

Copy link
Copy Markdown
Author

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenCode plugin only reads process.env.PATH, not Path — self-disables on Windows/Bun

4 participants