Question

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?

Was it helpful?

Solution

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

  • Make sure the Git pre-commit-hook is using at least Ruby 1.9
  • Use Guard::Jasmine version 1.14.0, which runs fine on Ruby 1.8

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

OTHER TIPS

best solution so far (at least for me):

rvm reload || exit $?
RUBY=`which ruby`
RUBY_DIR=`dirname $RUBY`
GEM_DIR=`rvm gemdir`
export PATH="$GEM_DIR/bin:$RUBY_DIR:$PATH"

gem install bundler
bundle install

bundle exec guard-jasmine
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top