That's a long title huh?
Anyway I got a combination of software I use with an issue that I cannot find the answer on the Internet.
Background
At the time of writing, I use
- SourceTree 3.2.1
- Git (latest, version doesn't matter)
- lefthook 0.7.7 (as git hook manager)
- asdf with ruby plugin
Lefthook Setup
I have hook scripts inside folder ./.githooks
under project root (all version controlled)
git config core.hooksPath .githooks
brew install lefthook
Workaround for source tree for path issue
sudo launchctl config user path `echo $PATH`
Ref:
- https://community.atlassian.com/t5/Bitbucket-questions/SourceTree-Hook-failing-because-paths-don-t-seem-to-be-set/qaq-p/274792#M33050
- https://apple.stackexchange.com/questions/51677/how-to-set-path-for-finder-launched-applications/198282#198282
Issue
I have recently switched from RVM to asdf.
After a restart of my computer I realize that one of my git hooks running bundle exec rubocop
no longer works.
The workaround above works for RVM.
Investigation
-
lefthook
binary is found (with workaround above) -
bundle
is using the binary from MacOS built-in Ruby
Solution
In my hook script pre-commit
Add the following before the code running lefthook
# ASDF compatibility
if test -f /usr/local/opt/asdf/libexec/asdf.sh ; then
. /usr/local/opt/asdf/libexec/asdf.sh
fi
if test -f /opt/homebrew/opt/asdf/libexec/asdf.sh ; then
. /opt/homebrew/opt/asdf/libexec/asdf.sh
fi
Top comments (0)