I have a pre-commit hook with the following:
#!/bin/sh
cd web
bundle exec guard-jasmine
(it cds into web because the Gemfile and app are set there)
When committing, I get a number of syntax errors, the first of which is this:
/Users/myusrname/.rvm/gems/ruby-2.0.0-p0/gems/guard-1.8.0/lib/guard.rb:400:in `require':
/Users/myusrname/.rvm/gems/ruby-2.0.0-p0/gems/guard-jasmine-1.16.0/lib/guard/jasmine.rb:25: odd number list for Hash (SyntaxError)
server: :auto,
/Users/myusrname/.rvm/gems/ruby-2.0.0-p0/gems/guard-jasmine-1.16.0/lib/guard/jasmine.rb:25: syntax error, unexpected ':', expecting '}'
server: :auto,
bundle exec guard-jasmine
and guard-jasmine
run fine when typed into the command line
Is there something that I'm missing?
It looks like guard-jasmine is running with Ruby 1.8.7, even if the RVM gem path contains ruby-2.0.0-p0. When using the new Ruby 1.9 Hash syntax in Ruby 1.8, the error odd number list for Hash (SyntaxError)
is thrown.
You need to either
Since Ruby 1.8.7 is end-of-life anyway, I'd suggest to try to initialize RVM in the pre-commit-hook:
#!/bin/sh
cd web
source "$HOME/.rvm/scripts/rvm"
rvm reload > /dev/null
bundle exec guard-jasmine
This implies you've set a default Ruby version
$ rvm --default use 1.9.2