Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tower Git Client compatability #18

Closed
JamieMason opened this issue Apr 30, 2015 · 12 comments
Closed

Tower Git Client compatability #18

JamieMason opened this issue Apr 30, 2015 · 12 comments

Comments

@JamieMason
Copy link

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;

ghooks-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.

@gtramontina
Copy link
Collaborator

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!

@JamieMason
Copy link
Author

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.

@gtramontina
Copy link
Collaborator

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 [email protected] 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.

@bjrmatos
Copy link

bjrmatos commented Sep 1, 2015

@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?

@JamieMason
Copy link
Author

@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.

@gittower-moved
Copy link

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

@kentcdodds
Copy link
Contributor

I have to start SourceTree from the command line to get it to load my path properly.

@gajus
Copy link

gajus commented Jul 15, 2016

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.

@gajus
Copy link

gajus commented Jul 15, 2016

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.

@JamieMason
Copy link
Author

JamieMason commented Jul 15, 2016 via email

@kentcdodds
Copy link
Contributor

We may actually make progress on #40. Subscribe to that issue to keep updated 👍

@ashblue
Copy link

ashblue commented Dec 13, 2017

@gajus Solution magically fixed some weird behavior on OSX High Sierra.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

7 participants