Open samholmes opened 1 year ago
environment variables loaded using: /bin/zsh -l
What happens when you run /bin/zsh -l -c env
?
Do you have anything in ~/.zlogin
?
This may be of use: https://blog.flowblok.id.au/2013-02/shell-startup-scripts.html
I don't have a .zlogin
. I only have the three files I've mentioned.
/bin/zsh -l -c env
loads .zshenv
and .zprofile
and shows my env. The PATH in this output is:
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Library/Apple/usr/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/samholmes/.deno/bin:/usr/local/sbin:/Users/samholmes/bin:/Applications/Sublime Text.app/Contents/SharedSupport/bin:/Users/samholmes/.radicle/bin:/Users/samholmes/.nvm/versions/node/v16.15.1/bin:/Users/samholmes/.cargo/bin:/Users/samholmes/Library/Android/sdk/emulator:/Users/samholmes/Library/Android/sdk/tools:/Users/samholmes/Library/Android/sdk/tools/bin:/Users/samholmes/Library/Android/sdk/platform-tools:/Users/samholmes/.foundry/bin:/Users/samholmes/.maestro/bin
This is certainly different from the PATH taken from the Debug Information.
I ran an experiment where I added a line to each of my zsh config files:
export LOADED="$LOADED .zshrc"
Where the file name is the name of the config file being loaded (.zshrc
, .zprofile
, and .zshenv
). I then ran echo $LOADED
in my precommit hook and got an empty string. This is in contrast to running the echo in my terminal:
❯ echo $LOADED
.zshenv .zprofile .zshrc
I added a echo $PATH
to my precommit hook just to ensure that echo works and it did output:
/Users/samholmes/.nvm/versions/node/v14.15.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/samholmes/Developer/edge-logs-server/node_modules/.bin:/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core:/Users/samholmes/.nvm/versions/node/v14.15.0/bin:/Users/samholmes/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
Yet, still no LOADED env.
I did env
in my precommit hook and got a significantly different result from the output from my terminal app.
It appears that Sublime Merge is not loading my zsh config files at all.
I've posted on the forum to try and get more help: https://forum.sublimetext.com/t/node-version-is-incorrect-when-running-precommit-hooks/67412
Version info
Description
It appears the PATH is not being set correctly by my
.zshenv
,.zprofile
, nor.zshrc
files. I have addedexport PATH="ZSHENV:$PATH
,export PATH="ZPROFILE"
, andexport PATH="ZSHRC"
to my.zshenv
,.zprofile
, and.zshrc
files, respectively. This allowed me to determine that PATH isn't being effected by these file because this is what is shown in the Debug Information:This is causing my git-hooks to fail because my hooks expect the right version of node to be used which is managed my NVM. The node version 14.15.0 is incorrect. The version of node that I expect is
v16.15.1
which is whatnode -v
returns from my terminal app.How can I debug why the PATH is not being set correctly? Is there a debug log file somewhere that shows more detail about what Sublime Merge is doing under the hood?