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

Prepending using shell integration does not work for zsh, even when shell integration is activated #205133

Closed
Tracked by #22879
karrtikr opened this issue Feb 13, 2024 · 7 comments · Fixed by #206994
Closed
Tracked by #22879
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders terminal-shell-integration Shell integration infrastructure, command decorations, etc. terminal-shell-zsh An issue in the terminal specific to zsh, including shell integration verified Verification succeeded
Milestone

Comments

@karrtikr
Copy link
Contributor

karrtikr commented Feb 13, 2024

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

Extension version: 2024.1.10391007
VS Code version: Code 1.86.0 (0504748, 2024-01-31T10:27:46.147Z)

Opening on behalf of @JoelFeiner-viimed: microsoft/vscode-python#22881, and @matt-hires: microsoft/vscode-python#22899

Steps to Reproduce:

  1. Prepending environment variable PATH in environment collection with /home/joel/.vscode/extensions/ms-python.python-2024.1.10441459/pythonFiles/deactivate/zsh:/home/joel/.local/share/virtualenvs/edge-49eYqZTG/bin: using options: {"applyAtShellIntegration":true,"applyAtProcessCreation":true}

  2. Value of PATH in zsh, notice how /home/joel/.vscode/extensions/ms-python.python-2024.1.10441459/pythonFiles/deactivate/zsh:/home/joel/.local/share/virtualenvs/edge-49eYqZTG/bin: appears exactly once despite prepending it twice

  3. Prepending environment variable PATH in environment collection with the same value using options: {"applyAtShellIntegration":true,"applyAtProcessCreation":false}

  4. Value of PATH in zsh

/home/joel/.pyenv/shims:/home/joel/bin:/home/joel/pycharm/bin:/home/joel/.nvm/versions/node/v16.20.0/bin:/home/joel/.pyenv/bin:/home/joel/bin:/home/joel/pycharm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin

Notice how the value is not prepended, both of them which suggests that automatic shell integration fails to prepend to PATH.

Relevant details:

.zshrc

export PATH="$HOME/bin:$HOME/pycharm/bin:$PATH"
export PAGER="less"
export LESS="$LESS -FRXK"
#export LESS="-iMSx4 -FX"

export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

setopt nointeractivecomments
setopt nosharehistory
unsetopt sharehistory

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

Shell integration is activated according to screenshot:

image

@vscodenpa
Copy link

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.86.1. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

@karrtikr
Copy link
Contributor Author

Btw, both 633 and 133 shell integration sequences were not reported via the terminal data write event, so automatic shell integration may not be working, despite saying it's activated?

@norambna
Copy link

norambna commented Feb 14, 2024

automatic shell integration may not be working, despite saying it's activated?

Yes, exactly this is happening on my system!

Version: 1.86.1
Commit: 31c37ee8f63491495ac49e43b8544550fbae4533
Date: 2024-02-07T09:07:19.849Z
Electron: 27.2.3
ElectronBuildId: 26495564
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Linux x64 6.5.13-7-MANJARO

@Tyriar Tyriar assigned meganrogge and unassigned Tyriar Mar 6, 2024
@Tyriar Tyriar added terminal-shell-integration Shell integration infrastructure, command decorations, etc. terminal-shell-zsh An issue in the terminal specific to zsh, including shell integration labels 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
@vscodenpa vscodenpa added the info-needed Issue requires more information from poster label Mar 6, 2024
@meganrogge
Copy link
Contributor

Since shell integration is getting activated, but the sequences are not coming through, the only thing I can imagine is that somewhere within our script, there's an error getting thrown so it exits before our sequences are put into place.

I see that you have powerlevel 10k sourced within your .zshrc. does commenting out these lines fix it?

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

@meganrogge
Copy link
Contributor

meganrogge commented Mar 6, 2024

@Tyriar reminded me that powerlevel 10k will disable our shell integration script from running by design as there were problems with the interplay of that and our shell integration.

@Tyriar
Copy link
Member

Tyriar commented Mar 6, 2024

We should be good to move the env stuff above the p10k exit to fix this problem:

# Shell integration was disabled by the shell, exit without warning assuming either the shell has
# explicitly disabled shell integration as it's incompatible or it implements the protocol.
if [ -z "$VSCODE_SHELL_INTEGRATION" ]; then
builtin return
fi

@Tyriar Tyriar reopened this Mar 6, 2024
@meganrogge meganrogge reopened this Mar 6, 2024
@Tyriar Tyriar added the bug Issue identified by VS Code Team member as probable bug label Mar 6, 2024
@Tyriar Tyriar modified the milestones: April 2024, March 2024 Mar 6, 2024
@Tyriar Tyriar assigned Tyriar and unassigned meganrogge Mar 6, 2024
Tyriar added a commit that referenced this issue Mar 6, 2024
@vscodenpa vscodenpa added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Mar 6, 2024
@rzhao271 rzhao271 removed the info-needed Issue requires more information from poster label Mar 26, 2024
@meganrogge meganrogge added the verified Verification succeeded label Mar 27, 2024
@meganrogge
Copy link
Contributor

Verified via code review

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders terminal-shell-integration Shell integration infrastructure, command decorations, etc. terminal-shell-zsh An issue in the terminal specific to zsh, including shell integration verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants