Tower Git Client compatability
JamieMason opened this issue ยท 12 comments
Hi @gtramontina,
Thanks so much for creating ghooks, our team use it every day and find it really useful.
There's one small issue though regarding support for GUI Git Clients such as Tower;
Searching for a fix, it looks like similar projects have also had this problem.
(I don't think this is environment related, but some output if needed)
$ /usr/bin/env node --version
v0.12.0
$ which node
/usr/local/bin/node
$ echo $PATH
/Users/jmason/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
I hope this is useful, thanks.
Hey there @JamieMason. Thanks for reporting this and the detailed info! ๐
Have you experienced this same issue with other GUIs? Can you please try to fiddle a little bit with the hooks under .git/hooks
(as suggested here: wecodemore/grunt-githooks#8 (comment)) and see how far you get?
Let me know!
The problem seems to be that Tower (and other GUIs from what I've read) use a different $PATH
/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core
:/Applications/Xcode.app/Contents/Developer/usr/bin
:/opt/homebrew-cask/Caskroom/tower/latest/Tower.app/Contents/Resources/git-flow
:/usr/bin
:/bin
:/usr/sbin
:/sbin
Incase it helps anyone (rather than throwing it away) the following workaround of executing sh
instead of node
and adding /usr/local/bin
to the $PATH
before executing node
inline will work on Mac.
#!/usr/bin/env sh
# Generated by ghooks. Do not edit this file.
PATH="$PATH:/usr/local/bin"
__dirname=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
__filename="${0##*/}"
ghooks_runner="
var path = require('path');
var dirname = '$__dirname';
var filename = path.resolve(dirname, '$__filename');
try {
require('ghooks')(dirname, filename);
} catch (e) {
console.warn([
'ghooks not found!',
'Make sure you have it installed in node_modules.',
'Skipping git hooks.'
].join('\n'));
}
"
node -e "$ghooks_runner"
Closing as in hindsight I think this is probably really an issue for @gittower.
Wow! :-)
Thanks a lot for the deep dive.
I'll add a note to README pointing here.
Sent from my iPhone
On Jun 1, 2015, at 6:08 AM, Jamie Mason notifications@github.com wrote:
The problem seems to be that Tower (and other GUIs from what I've read) use a different $PATH
/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core
:/Applications/Xcode.app/Contents/Developer/usr/bin
:/opt/homebrew-cask/Caskroom/tower/latest/Tower.app/Contents/Resources/git-flow
:/usr/bin
:/bin
:/usr/sbin
:/sbin
Incase it helps anyone (rather than throwing it away) the following workaround of executing sh instead of node and adding /usr/local/bin to the $PATH before executing node inline will work on Mac.#!/usr/bin/env sh
Generated by ghooks. Do not edit this file.
PATH="$PATH:/usr/local/bin"
__dirname=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
__filename="${0##*/}"ghooks_runner="
var path = require('path');
var dirname = '$__dirname';
var filename = path.resolve(dirname, '$__filename');try {
require('ghooks')(dirname, filename);
} catch (e) {
console.warn([
'ghooks not found!',
'Make sure you have it installed in node_modules.',
'Skipping git hooks.'
].join('\n'));
}
"node -e "$ghooks_runner"
Closing as in hindsight I think this is probably really an issue for @gittower.โ
Reply to this email directly or view it on GitHub.
@JamieMason i'm a little confused.. how i can apply this workaround? do i need to modify all the hooks everytime i clone my project on a new machine?
@bjrmatos it's something that @gtramontina (or a contributor) would need to apply to ghooks itself so that it works with these GUI apps โ more work is needed though to test and finish it before it could be used.
When you run Git from the command line, it runs in the environment as set up by your Shell. GUI OS X apps, however, have no knowledge about your shell - and the PATH environment can be changed in many different places.
See Tower's online docs for more info on how to deal with this: http://git-tower.com/help/mac/faq-and-tips/faq/hook-scripts
I have to start SourceTree from the command line to get it to load my path properly.
For the record, the simpler way to work around this (assuming your git hooks depend on environment variables set by the shell), is to simply start Git Tower from the CLI, e.g.
gittower ./any-repository
This will open Git Tower client aware of the environment variables set by the shell script.
I find it a bit odd though that Tower GUI simply cannot source ./bashrc
. I'd imagine that there are quite a few developers that use ./bashrc
(or equivalent) to setup their working environment, e.g. nvm use node
.
We may actually make progress on #40. Subscribe to that issue to keep updated ๐