Prepending PATH env var with environmentVariableCollection doesn't work on macOS
See original GitHub issueThis was covered a little bit in https://github.com/microsoft/vscode/issues/94153 but that issue is locked and can’t be discussed there. This feature feels pretty broken on macOS and I hope might be revisited.
The issue is on macOS prepending to PATH
:
context.environmentVariableCollection.prepend("PATH", "/foo/my/path:");
This ends up being added to the end of the path, rather than the start. @Tyriar wrote up why this is in microsoft/vscode-docs@38653d4 and offered two workarounds, however neither of them are usable in my testing (as well as not really being feasible to tell all users to change):
"terminal.integrated.inheritEnv": false
makes no difference at all, the PATH till is added to the end (this is a problem because the purpose of usingprepend
above is that we need to override any existing SDK on PATH with the one the user just selected)"terminal.integrated.shellArgs": []
results in a completely emptyPATH
besides the values I’ve prepended, which means that pretty much everything else is missing and won’t work. This might be solvable by pushingprocess.env.PATH
intoenvironmentVariableCollection
too, however the prompt to the user would look ridiculous as it would include their entire PATH
I appreciate this probably isn’t VS Code’s fault, but given macOS is fairly common and this behaviour seems to happen on a clean macOS install (it happens on both of mine, and I’ve customised almost nothing) it feels like it’s worth trying to fix (maybe even if it means sending export PATH=foo:$PATH
once the shell is initialised? 😄).
Issue Analytics
- State:
- Created 3 years ago
- Reactions:24
- Comments:15 (11 by maintainers)
Top GitHub Comments
Awesome, thanks! I’m definitely interested in testing this if/when there’s something more concrete 😃
@DanTup actually had a discussion with the Python team around this so I’m guessing this will get prioritized soon. The way I’m envisioning this working is for some environment variable being set (VSCODE_ENV_CONTRIBUTION or something?) and the shell integration script checking that and re-applying it after the init scripts run