tarmolov / git-hooks-js

A tool to manage and run project git hooks
167 stars 30 forks source link

Git GUI clients: 'env: node' not found #44

Closed damon-kreft closed 7 years ago

damon-kreft commented 7 years ago

First of all, great job. This module has been key in improving our team's QA.

I and many Dev's I work with have moved away from Git on the command line in favour of a Git GUI (Github Desktop, Tower, Kaleidoscope etc) and it's at this point purists generally scoff at the idea 😛 but the fact is (for us at least), passed merging and branching it becomes archaic to do anything more complex and productivity is improved through these tools and that's what really matters to us.

But unfortunately, several GUI's I've tried on macOS don't play nicely this library and it's because each generated hook script is set to #!/usr/bin/env node which results in the error 'env: node not found' as the client isn't aware of the env path that has been set for the current user session.

I've manually updated each generated hook script to #!/usr/bin/env /usr/local/bin/node which works.

I appreciate there may be pitfalls for automatically detecting the full path to the node bin e.g. which node returns my NVM managed node bin /Users/me/.nvm/versions/node/v7.9.0/bin/node, which could easily change in the future. Is there a .gitignore'able way to explicitly specify the node path as part of config perhaps?

Thanks

EDIT: tried various workarounds such as setting the PATH globally (e.g. /etc/profile) but some GUI's don't honour this.

tarmolov commented 7 years ago

nvm should change your path and it usually works well. I don't work with IDE and GUI utils. My main tools is vim editor.

Anyway I want to help you to solve your issue.

I see to possible options which you can do on your side:

  1. Change $PATH (maybe gui has some preferences about it)
  2. Add symlink like ln -s /usr/local/bin/node /usr/bin/node

Please let me know if it helps or not. We'll figure out how to fix it.