I’ve set up a pre-commit hook that runs when I commit from the terminal, but doesn’t when I do it from Github Desktop for Mac. Any ideas why this isn’t working?
@matt-tyler-eb GitHub Desktop ships with an internal version of Git which we use for all actions inside the app. As such the environment within which your commit hooks execute will likely not exactly match that of your normal environment. Are you seeing any error messages?
It’d also be helpful if you could take a look at the log to see if there is anything being shown there. To access the log files go to the file menu in GitHub Desktop and select
Not seeing any errors, it commits fine, it just doesn’t run my pre-commit hook. I’ve copied the logs below, it looks like the last one is the only one that is related, and it just indicates a successful commit as far as I can tell. How can I adjust my environment variables for GitHub Desktop to match the ones in my terminal?
2021-09-07T19:43:03.848Z - info: [ui] [AppStore.withAuthenticatingUser] account found for repository: whatever - matt-tyler-eb (has token) 2021-09-07T19:43:05.788Z - info: [ui] Executing fetch: git -c credential.helper= -c protocol.version=2 fetch --progress --prune origin (took 1.927s) 2021-09-07T19:43:08.979Z - info: [ui] [RepositoryIndicatorUpdater]: Refreshing sidebar indicators for 20 repositories took 8.7s of which 0.0s paused, total 8.7s 2021-09-07T19:43:16.619Z - info: [ui] [Timing] Action 'create commit' for 'eventbrite/myRepository' took 1.118s
False alarm. I got an error when I ran my pre-commit script manually from the terminal saying
dyld: Library not loaded: @rpath/lib_InternalSwiftSyntaxParser.dylib and that pointed to my Xcode being configured incorrectly (I’m doing iOS development). Turned out since I had switched to a beta version of Xcode, it couldn’t find the Xcode command line tools that were being referenced within my pre-commit script and it was aborting when it hit that error. My problems were solved by pointing back to the official release of Xcode and pointing my xcode-select command line tools to that version. I did this with the following command:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
And it works now. Thanks for your help in pointing me towards the surrounding environment variables!
Glad to hear you were able to get things working!