-
Notifications
You must be signed in to change notification settings - Fork 146
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
Indicate zshenv is to be used when configuring ZSH version managers #2239
base: main
Are you sure you want to change the base?
Indicate zshenv is to be used when configuring ZSH version managers #2239
Conversation
@@ -8,18 +8,18 @@ with the same Ruby version as your projects, we need to properly set these envir | |||
invoking your Ruby version manager. | |||
|
|||
The extension runs a command using your shell's interactive mode, so that version managers configured in files such as | |||
`~/.zshrc` are picked up automatically. The command then exports the environment information into JSON, so that we can | |||
`~/.zshenv` are picked up automatically. The command then exports the environment information into JSON, so that we can |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a zsh user. Does this file always exist? Or could there be users that don't have this file and only have ~/.zshrc
?
I'm trying to understand if this is a recommendation that would work for everyone or if it might require extra steps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's dependent of your ZSH setup. I run ZSH with Prezto. My ruby is sourced in ~/.zshrc
with Mise and it works. So i'm not sure the doc change cover all cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vinistock I created this file when testing this functionality.
@louim I attempted to source from ~/.zshrc
and it failed to initialize. :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justinbburris strange, rbenv init
will either write itself to ~/.zshrc
or ~/.zprofile
: https://github.com/rbenv/rbenv/blob/3bac268cdb81dd745ce13a1cf6ff4a286336ab3b/libexec/rbenv-init#L115-L124. Maybe something else on your setup is interfering with rbenv?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This (somewhat old) blog post explain in which order ZSH load files: https://shreevatsa.wordpress.com/2008/03/30/zshbash-startup-files-loading-order-bashrc-zshrc-etc/. ~/.zshrc
should always be loaded, either in login or non-login mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
per zsh docs it will run /etc/zprofile
after ~/.zshenv
which, on recent versions of macOS at least, does things like put the system ruby ahead of rbenv, asdf etc in PATH.
I had to do asdf init, for example, inside my ~/.zprofile
which gets sourced after /etc/zprofile
. I'm not particularly knowledgable here, but the docs suggest this depends on how zsh is invoked and for what type of session.
Motivation
Closes #2202
When configuring your ZSH based shell, we want to make sure the right file is indicated.
Implementation
Tested the tool via booting up the extension in VS Code.
Automated Tests
They're just readme changes, so modification of features.
Manual Tests
(I used rbenv for as my ruby version manager)
zshrc
, and open VS Code. You'll see the extension fail to initializezshenv
, and open VS Code. You'll see the extension initialize