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

nvm not found in git hook shell files #688

Closed
RichardLitt opened this issue Mar 9, 2015 · 2 comments
Closed

nvm not found in git hook shell files #688

RichardLitt opened this issue Mar 9, 2015 · 2 comments

Comments

@RichardLitt
Copy link

I've got a pre-commit git hook that bundles code for me, and my bundling process requires v0.12 at the moment as there's an issue with iojs one of my deps can't take. I've set my default using nvm alias default v0.12, but I think my system is still using iojs, because when I commit I get the error I would expect if I did. I think the issue is that but my git hook shell script can't seem to find nvm, and defaults to system.

I added these lines to the hook:

which node
nvm ls

And got:

$ sh .git/hooks/pre-commit
/Users/richard/.nvm/versions/node/v0.12.0/bin/node
.git/hooks/pre-commit: line 7: nvm: command not found

And now I am confused - why is nvm not found?

@ljharb
Copy link
Member

ljharb commented Mar 9, 2015

What kind of shell does the git hook execute with? If it's a non-interactive shell, it probably doesn't source nvm.sh. Try adding . $NVM_DIR/nvm.sh to your git hook. (it might be explicitly preserving your PATH but not the shell environment)

Also, what version of git are you using?

@RichardLitt
Copy link
Author

That did it! I guess it's non-interactive.

Not relevant anymore, but:

$ git --version
git version 2.3.0
hub version 2.2.0-rc1-g1409606

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

No branches or pull requests

2 participants