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

Shell integration zsh hooks don't load on macOS/Linux sometimes #141620

Closed
roblourens opened this issue Jan 27, 2022 · 11 comments · Fixed by #143305
Closed

Shell integration zsh hooks don't load on macOS/Linux sometimes #141620

roblourens opened this issue Jan 27, 2022 · 11 comments · Fixed by #143305
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders linux Issues with VS Code on Linux macos Issues with VS Code on MAC/OS X terminal-shell-integration Shell integration infrastructure, command decorations, etc. verified Verification succeeded
Milestone

Comments

@roblourens
Copy link
Member

roblourens commented Jan 27, 2022

Testing #141339

I get this error in the terminal, on Linux using zsh

/snap/code-insiders/917/usr/share/code-insiders/resources/app/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-zsh.sh: 50: /snap/code-insiders/917/usr/share/code-insiders/resources/app/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-zsh.sh: Syntax error: word unexpected (expecting ")")
$ zsh --version
zsh --version
zsh 5.4.2 (x86_64-ubuntu-linux-gnu)
@Tyriar
Copy link
Member

Tyriar commented Jan 27, 2022

Can repro with plain zsh installed via apt

@Tyriar Tyriar added bug Issue identified by VS Code Team member as probable bug terminal-shell-integration Shell integration infrastructure, command decorations, etc. labels Jan 27, 2022
@Tyriar Tyriar added this to the January 2022 milestone Jan 27, 2022
@Tyriar
Copy link
Member

Tyriar commented Jan 27, 2022

The problem lines are:

precmd_functions+=($precmd_functions precmd)
preexec_functions+=($preexec_functions preexec)

I tried to use autoload and add-zsh-hook which I think is the more portable way to do this, but I get autoload: not found for some reason. This is with zsh 5.8.

@Tyriar
Copy link
Member

Tyriar commented Jan 28, 2022

It's a shame but let's defer, we can call out that there's a known issue with zsh in the release notes.

@Tyriar Tyriar modified the milestones: January 2022, February 2022 Jan 28, 2022
@Tyriar Tyriar added the linux Issues with VS Code on Linux label Jan 28, 2022
@Tyriar
Copy link
Member

Tyriar commented Jan 28, 2022

There's also some issue @rzhao271 was hitting which seems related to using macOS' default zsh, not the homebrew install #140784 (comment)

@Tyriar Tyriar added the macos Issues with VS Code on MAC/OS X label Jan 28, 2022
@Tyriar Tyriar changed the title shellIntegration-zsh.sh error Shell integration zsh hooks don't load on macOS/Linux sometimes Jan 28, 2022
@gmessow-cxomni
Copy link

I had the same problem with under Linux (with oh-my-zsh, don't know if this relevant).

The following changes to the integration shell script helped:

Add as first line: #!/bin/zsh

Added at line 49:
typeset -a precmd_functions preexec_functions

Change line 50 and 51 to:
precmd_functions+=(precmd)
preexec_functions+=(preexec)

@Tyriar
Copy link
Member

Tyriar commented Feb 4, 2022

@gmessow-cxomni thanks for the info, I'm relatively new to zsh scripting so this should be handy

@Tyriar
Copy link
Member

Tyriar commented Feb 15, 2022

Spent some time looking into this and here's my understanding of what's happening. We launch zsh with shell integration using:

zsh -c '"${execInstallFolder}/out/vs/workbench/contrib/terminal/browser/media/shellIntegration.zsh"; zsh -i'

Since -c is used, autoload, add-zsh-hook, etc. aren't available which is messing everything up. I don't know why results are inconsistent across machines but that's the theory, so the fix would be to move to something closer to what bash does where we source rc/profile within the shell integration script.

@roblourens
Copy link
Member Author

Can't verify, due to #143389

@Tyriar Tyriar added the verification-steps-needed Steps to verify are needed for verification label Feb 24, 2022
@Tyriar
Copy link
Member

Tyriar commented Feb 24, 2022

Added verification steps needed to deter people from trying until it's fixed (hopefully today or tomorrow: #143629)

@Tyriar
Copy link
Member

Tyriar commented Feb 28, 2022

Ready to verify after today's insiders goes out

@Tyriar Tyriar removed the verification-steps-needed Steps to verify are needed for verification label Feb 28, 2022
@Tyriar
Copy link
Member

Tyriar commented Feb 28, 2022

Actually, this has the same verification steps as #143629 so adding verified here and deferring to that issue.

@Tyriar Tyriar added the verified Verification succeeded label Feb 28, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 4, 2022
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 linux Issues with VS Code on Linux macos Issues with VS Code on MAC/OS X terminal-shell-integration Shell integration infrastructure, command decorations, etc. verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants
@roblourens @Tyriar @meganrogge @gmessow-cxomni and others