Details
-
Bug
-
Resolution: Unresolved
-
Low
-
None
-
4.2.7
-
None
-
Severity 2 - Major
Description
Setup configuration
- Macbook Air M1 2020
- macOS Sonoma 14.4.1
- OhMyZsh
- SourceTree (v4.2.7)
When trying to commit, my pre commit hook fails to execute as it is trying to use system installed Ruby 2.6 instead of my asdf installed Ruby 3.1.3
System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': Could not find 'bundler' (2.4.10) required by your /Users/paul.louis/{...omitted for confidentiality...}/Gemfile.lock.
Investigation shows issue comes from order in which PATH elements are loaded into by Sourcetree. Adding an echo $PATH to my precommit hook reveals the following
This is $PATH in Sourcetree
/Users/paul.louis/.asdf/plugins/nodejs/shims
/Users/paul.louis/.asdf/installs/nodejs/20.10.0/bin
/Library/Developer/CommandLineTools/usr/libexec/git-core
/Applications/Sourcetree.app/Contents/Resources/bin
/usr/bin <- System Ruby 2.6 found here
/Applications/Sourcetree.app/Contents/Resources/git_local/gitflow
/Applications/Sourcetree.app/Contents/Resources/git_local/git-lfs
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/MacGPG2/bin
/opt/homebrew/bin
/Users/paul.louis/.bin
/Users/paul.louis/.asdf/shims
/Users/paul.louis/.asdf/bin
/opt/homebrew/bin
/opt/homebrew/sbin
/System/Cryptexes/App/usr/bin
/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
/usr/local/MacGPG2/bin
and this is $PATH from a regular zsh console
/opt/homebrew/bin
/Users/paul.louis/.bin
/Users/paul.louis/.asdf/shims <- asdf installed Ruby 3.1.3 found here
/Users/paul.louis/.asdf/bin
/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
/usr/local/MacGPG2/bin
For reference, removing all comments, my .zshrc looks like this
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="robbyrussell"
plugins=(git)
source $ZSH/oh-my-zsh.sh
export PATH="$HOME/.bin:$PATH"
export PATH="/opt/homebrew/bin:$PATH"