Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PATH mutation using EnvironmentVariableCollection prepend is overwritten in zsh #188235

Open
hyangah opened this issue Jul 19, 2023 · 10 comments
Open
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug macos Issues with VS Code on MAC/OS X terminal-process Problems launching processes, managing ptys, exiting, process leaks, etc.
Milestone

Comments

@hyangah
Copy link

hyangah commented Jul 19, 2023

  • VS Code Version: 1.80.1
  • OS Version: Darwin x64 22.5.0

VS Code Go extension tries to change the integrated terminals' PATH environment variable using EnvironmentVariableCollection.prepend api.

I verified that the change contribution is known to vscode using "Terminal: Show Environment Contributions" command.

# Terminal Environment Changes

## Extension: golang.go

- `PATH=/Users/hakim/sdk/go1.20.3/bin:${env:PATH}`

## Extension: vscode.git

- `GIT_ASKPASS=/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/git/dist/askpass.sh`
...

When I create a terminal tab with bash, I see the PATH change applied and go sdk path prepended as expected.

But, when I create a terminal with zsh, it looks like zsh prepends the login shell PATH again after applying our extension's PATH change.

Note all "terminal.integrated.profiles.*" settings were default.

A workaround I found is to remove "-l" arg from the default "terminal.integrated.profiles.osx.zsh" setting. But I don't know if it's ok to recommend this change to all zsh users. I see the default "terminal.integrated.profiles.osx.bash" also has "-l" but this bad interaction doesn't happen. Is it a known issue, or it is WAI?

@meganrogge meganrogge added the terminal-process Problems launching processes, managing ptys, exiting, process leaks, etc. label Jul 19, 2023
@Tyriar
Copy link
Member

Tyriar commented Jul 24, 2023

This is because login shells on macOS completely reset the environment. We have a proposal coming that will let you work around this by setting it via shell integration which runs after the login init scripts #179476

@Tyriar Tyriar closed this as completed Jul 24, 2023
@lowang-bh
Copy link

removing "-l" arg from the default "terminal.integrated.profiles.osx.zsh" setting does not work for me.
image

@Tyriar
Copy link
Member

Tyriar commented Jul 26, 2023

Actually this was meant to be fixed by #99878. The fix will oly work if you have shell integration enabled. Do you see these dots to the left of the terminal?

image

@uruemu
Copy link

uruemu commented Aug 31, 2023

@Tyriar I see those dots and seem to have shell integration enabled but still have the same issue. I am also using go version manager gvm

Screenshot 2023-08-31 at 7 57 07 AM

@Tyriar Tyriar reopened this Aug 31, 2023
@Tyriar Tyriar added this to the Backlog milestone Aug 31, 2023
@wulling1024
Copy link

hi @Tyriar any update? I also encountered the same problem. Go env cannot be activated when using zsh.
cc: @hyangah

  • vscode version:
    Version: 1.83.1
    Commit: f1b07bd
    Date: 2023-10-10T23:46:55.789Z
    Electron: 25.8.4
    ElectronBuildId: 24154031
    Chromium: 114.0.5735.289
    Node.js: 18.15.0
    V8: 11.4.183.29-electron.0
    OS: Darwin x64 22.6.0

  • terminal configuration:
    image

@pedronasser
Copy link

pedronasser commented Nov 29, 2023

Cool. Time to downgrade VSCode again...

@NeonWizard
Copy link

NeonWizard commented Dec 12, 2023

Same issue here, shouldn't this be prioritized? This is heavily affecting the development process at my company and I'm sure a lot of other people

@meganrogge meganrogge added bug Issue identified by VS Code Team member as probable bug and removed confirmation-pending labels Dec 18, 2023
@glebarez
Copy link

glebarez commented Feb 9, 2024

this is the second time i come across this bug.
the suggested "remove -l for zsh" doesn't work this time.
What helped:

WARNING: this is VSCode factory reset
https://stackoverflow.com/a/64518036/11362891

@vishalwadhwa13
Copy link

Hi team, facing the same issue. Any alternate solutions?

@coderbean
Copy link

same issue, changed to bash to avoid it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug macos Issues with VS Code on MAC/OS X terminal-process Problems launching processes, managing ptys, exiting, process leaks, etc.
Projects
None yet
Development

No branches or pull requests

12 participants