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

.zshrc is overriding the environment variable set by shell integration on macOS #205102

Closed
Tracked by #22879
karrtikr opened this issue Feb 13, 2024 · 4 comments
Closed
Tracked by #22879
Assignees
Labels
confirmation-pending info-needed Issue requires more information from poster terminal-shell-integration Shell integration, command decorations, etc. terminal-shell-zsh An issue in the terminal specific to zsh
Milestone

Comments

@karrtikr
Copy link
Contributor

karrtikr commented Feb 13, 2024

Does this issue occur when all extensions are disabled?: Yes/No

Reporting on behalf of @pquadri: microsoft/vscode-python#22901

VS Code version: Code 1.86.1 (Universal) (31c37ee, 2024-02-07T09:09:01.236Z)
OS version: Darwin arm64 23.3.0

Steps to Reproduce:

  1. Python extension sets the environment variable collection using EnvironmentCollection.prepend API, by using options: {"applyAtShellIntegration":true,"applyAtProcessCreation":true}:
Prepending environment variable PATH in collection with value "<prepend>"
  1. Value of PATH in zsh terminal:
/Users/paolo.quadri/.local/bin:/Users/paolo.quadri/.asdf/shims:/opt/homebrew/opt/asdf/libexec/bin:<prepend>:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:<prepend>

As one can notice <prepend> is appearing twice, which is expected, but .zshrc seems to be running after it which is why <prepend> isn't the first entry in PATH.
image
shell integration:
image

@Tyriar
Copy link
Member

Tyriar commented Mar 6, 2024

As one can notice is appearing twice, which is expected, but .zshrc seems to be running after it which is why isn't the first entry in PATH.

.zshrc is meant to be called before here:

# Only fix up ZDOTDIR if shell integration was injected (not manually installed) and has not been called yet
if [[ "$VSCODE_INJECTION" == "1" ]]; then
if [[ $options[norcs] = off && -f $USER_ZDOTDIR/.zshrc ]]; then
VSCODE_ZDOTDIR=$ZDOTDIR
ZDOTDIR=$USER_ZDOTDIR
# A user's custom HISTFILE location might be set when their .zshrc file is sourced below
. $USER_ZDOTDIR/.zshrc
fi
fi

@meganrogge might know more as she's the main maintainer of the zsh script and daily drives it.

@Tyriar Tyriar added confirmation-pending terminal-shell-integration Shell integration, command decorations, etc. terminal-shell-zsh An issue in the terminal specific to zsh labels Mar 6, 2024
@Tyriar Tyriar removed their assignment Mar 6, 2024
@Tyriar Tyriar added this to the March 2024 milestone Mar 6, 2024
@meganrogge meganrogge modified the milestones: March 2024, April 2024 Mar 6, 2024
@meganrogge
Copy link
Contributor

meganrogge commented Mar 6, 2024

I cannot reproduce the issue, so it seems likely that the user's configuration is causing this.

I've added export PATH="/path-appended-in-zshrc:$PATH" to my .zshrc.

In the extension sample, I've added:

const collection = context.environmentVariableCollection;
collection.prepend('PATH', 'path-prepended-in-extension', { applyAtShellIntegration: true });

The below shows that this works. I am guessing there's some issue happening for certain configurations that causes our shell integration script to fail / not get run.

Image

@karrtikr
Copy link
Contributor Author

karrtikr commented Mar 6, 2024

@pquadri Is this still an issue for you?

@meganrogge meganrogge added the info-needed Issue requires more information from poster label Mar 6, 2024
@VSCodeTriageBot
Copy link
Collaborator

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@VSCodeTriageBot VSCodeTriageBot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 14, 2024
@microsoft microsoft locked and limited conversation to collaborators Jun 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
confirmation-pending info-needed Issue requires more information from poster terminal-shell-integration Shell integration, command decorations, etc. terminal-shell-zsh An issue in the terminal specific to zsh
Projects
None yet
Development

No branches or pull requests

4 participants