Skip to content

Prepending PATH env var with environmentVariableCollection doesn't work on macOS #99878

@DanTup

Description

@DanTup

This was covered a little bit in #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 using prepend 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 empty PATH besides the values I've prepended, which means that pretty much everything else is missing and won't work. This might be solvable by pushing process.env.PATH into environmentVariableCollection 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? 😄).

Metadata

Metadata

Assignees

Labels

apifeature-requestRequest for new features or functionalityinsiders-releasedPatch has been released in VS Code InsidersmacosIssues with VS Code on MAC/OS Xterminal-shell-integrationShell integration infrastructure, command decorations, etc.verification-neededVerification of issue is requestedverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions