fix: normalize PATH env key casing to prevent tool detection failures on Windows#1966
fix: normalize PATH env key casing to prevent tool detection failures on Windows#1966cpc5622 wants to merge 3 commits intoAndyMik90:developfrom
Conversation
… on Windows
On some Windows versions (e.g. Windows 10), `{ ...process.env }` spreads
environment variables with the native key casing 'Path' instead of 'PATH'.
Since `getAugmentedEnv()` accesses `env.PATH`, this resulted in `undefined`,
silently dropping the entire original system PATH.
This caused detection failures for any tools installed in non-standard
locations. For example, when Node.js is installed on a non-C drive
(e.g. D:\NodeJs\), detecting Claude Code would fail with:
'node' is not recognized as an internal or external command
because `claude.cmd` (npm-generated wrapper) internally invokes `node`,
which was no longer on the subprocess PATH. The same issue affected gh,
Python, and other tools not in COMMON_BIN_PATHS.
The fix reuses the existing `normalizeEnvPathKey()` from agent/env-utils.ts
to ensure the PATH key is consistently uppercase before any access, applied
to both `getAugmentedEnv()` and `getAugmentedEnvAsync()`.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical issue on Windows where the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds normalization of the PATH-like environment key on Windows to Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request effectively addresses a critical bug on Windows where the system PATH was being dropped due to case-sensitivity issues with the PATH environment variable. The fix is clean and correctly utilizes the existing normalizeEnvPathKey utility. My feedback focuses on improving maintainability by making the new comments more concise and removing duplication, as the detailed context is already well-captured in the pull request description.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Summary
On some Windows versions (e.g. Windows 10),
{ ...process.env }produces the native key casingPathinstead ofPATH. SincegetAugmentedEnv()accessesenv.PATH, the value isundefined, causing the entire original system PATH to be silently dropped.This leads to detection failures for any tools installed in non-standard locations. For example, when Node.js is installed on a non-C drive (e.g.
D:\NodeJs\), detecting Claude Code fails with:This happens because
claude.cmd(the npm-generated wrapper) internally invokesnode, which is no longer on the subprocess PATH. The same issue affectsgh,python, and any other tool not in the hardcodedCOMMON_BIN_PATHS.Root Cause
Debug output confirming the bug:
After
getAugmentedEnv()runs, the env object contains dual keys (Path+PATH), wherePATHonly has hardcodedCOMMON_BIN_PATHS(all C-drive) and the originalPathwith user-configured paths is ignored.Fix
Reuse the existing
normalizeEnvPathKey()fromagent/env-utils.ts(which was already written to solve this exact casing issue for agent spawning) in bothgetAugmentedEnv()andgetAugmentedEnvAsync(), right after spreadingprocess.env.Changes:
normalizeEnvPathKeyfrom./agent/env-utilsnormalizeEnvPathKey(env)after{ ...process.env }in both sync and async versionsTest plan
D:\NodeJs\), verify Claude Code is detected successfullyghandpythonare detected when installed in non-standard locationsnpm run typecheck— passesnpm run lint— passes (no new errors)🤖 Generated with Claude Code
Summary by CodeRabbit