Conversation
SHELL is a POSIX convention Windows never sets, so detectShellProfile() always fell back to .bashrc there. Git Bash's default launch is a login shell, which reads .bash_profile / .bash_login / .profile — never .bashrc — so the injected env block was written to a file the shell never sources. Scoped to win32 only: prefer whichever of the three login-profile files already exists (bash's own lookup order), falling back to creating .bash_profile — the convention most Windows dev tooling (nvm-windows, etc.) already targets. Non-Windows bash is unaffected and still correctly gets .bashrc. Filed separately at @jeff-r2026's request in Tencent#661. Note: src/uninstall.ts has an identical, unfixed copy of this same detectShellProfile() logic. Left out of this PR since Tencent#682 scoped the fix to env.ts specifically, but flagging it — a Windows uninstall would still look in .bashrc to remove the block this now writes elsewhere.
|
Collaborator
|
Please resolve the conflicts |
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.
Summary
detectShellProfile()always fell back to.bashrcon Windows, sinceSHELL(a POSIX convention) is never set there. But Git Bash's default launch is a login shell, which reads.bash_profile/.bash_login/.profile— never.bashrc. The injected env block gets written, the file looks correct, and the variables are never loaded. Scoped towin32only; the existing macOS/Linux behavior is untouched.Type of Change
Test Plan
npx tsc --noEmitpassesnpx vitest runpasses — 264 files, 3622 tests, including 7 new cases for this changeReal, end-to-end verification (not only unit tests), per the repo's testing rule:
I don't have a Windows machine, so I couldn't run the literal Git Bash repro from the issue. Instead I did the next most honest thing:
npx tsccompiled the real source to plain JS (not the tsup CLI bundle, which has no importable exports), then ran a standalone Node script against that actual compiled artifact — real module resolution, realfs.existsSynccalls, realEnvHandlerclass, withprocess.platformand a real temp$HOMEswapped in (not mocked at the vitest level):.bash_loginand.profilefallback (the two other cases) are covered by the added Vitest cases, which also use realfs/temp-dir operations, not mocks of the function under test.Related Issues
Fixes #682
Notes for Reviewers
src/uninstall.tshas an identical, unfixed copy of this samedetectShellProfile()logic (not a call to the one inenv.ts). Left out of this PR since detectShellProfile() falls back to ~/.bashrc on Windows, where the login shell never reads it #682 scoped the fix toenv.tsspecifically, and the two files' logic isn't shared — but flagging it explicitly: a Windows uninstall would still look in.bashrcto remove the block this PR now writes to.bash_profile/.bash_login/.profile, silently leaving it behind. Worth a follow-up (either a mirrored fix or extracting the shared helper theenv.tsdocstring already gestures at: "a second spelling of this choice would... report a correct install as broken" — the same risk now applies betweenenv.tsanduninstall.ts).