Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Guard Giving "uninitialized constant Listen::Turnstile (NameError)" Error

I'm having this error while trying to run the command:

guard

This is an app I've been developing for a while now before trying to install guard...

I'm following the instructions from Ryan Bates' tutorial on guard:

http://railscasts.com/episodes/264-guard

Here's my Gem file.

source 'https://rubygems.org'

gem 'rails', '3.2.14'
gem 'rake'
gem 'mysql2'
gem 'bcrypt-ruby'
gem 'devise'
gem 'rails_admin'
gem 'jbuilder'
gem 'gon'
gem 'dynamic_form'
gem 'therubyracer', :require => 'v8'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'rails3-jquery-autocomplete'
gem 'roo'

group :assets do
  gem 'sass-rails', '~> 3.2.4'
  gem 'coffee-script', '~> 2.2.0'
  gem 'uglifier', '~> 1.2.3'
end

group :development, :test do
  gem 'capistrano'
  gem 'bullet'
  gem 'rvm-capistrano'
  gem 'better_errors'
  gem 'rspec-rails', '2.10.0'
  gem 'awesome_print'
  gem 'wirble'
  gem 'thin'
  gem 'guard-rspec'
  gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i  
end

group :test do
  gem 'capybara', '1.1.2'
  gem 'faker'
  gem 'factory_girl_rails'
  gem 'spork', '~> 1.0rc'
end

Here's the full error:

app3 git:(write-tests) ✗ guard
    /Users/Nick/.rvm/gems/ruby-1.9.3-p448/gems/guard-1.4.0/lib/guard.rb:47:in `setup': uninitialized constant Listen::Turnstile (NameError)
        from /Users/Nick/.rvm/gems/ruby-1.9.3-p448/gems/guard-1.4.0/lib/guard.rb:155:in `start'
        from /Users/Nick/.rvm/gems/ruby-1.9.3-p448/gems/guard-1.4.0/lib/guard/cli.rb:104:in `start'
        from /Users/Nick/.rvm/gems/ruby-1.9.3-p448/gems/thor-0.18.1/lib/thor/command.rb:27:in `run'
        from /Users/Nick/.rvm/gems/ruby-1.9.3-p448/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
        from /Users/Nick/.rvm/gems/ruby-1.9.3-p448/gems/thor-0.18.1/lib/thor.rb:363:in `dispatch'
        from /Users/Nick/.rvm/gems/ruby-1.9.3-p448/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
        from /Users/Nick/.rvm/gems/ruby-1.9.3-p448/gems/guard-1.4.0/bin/guard:6:in `<top (required)>'
        from /Users/Nick/.rvm/gems/ruby-1.9.3-p448/bin/guard:23:in `load'
        from /Users/Nick/.rvm/gems/ruby-1.9.3-p448/bin/guard:23:in `<main>'
        from /Users/Nick/.rvm/gems/ruby-1.9.3-p448/bin/ruby_noexec_wrapper:14:in `eval'
        from /Users/Nick/.rvm/gems/ruby-1.9.3-p448/bin/ruby_noexec_wrapper:14:in `<main>'
like image 301
Nick Res Avatar asked Oct 11 '13 15:10

Nick Res


2 Answers

You don't have gem "guard" in your gem file.

I was getting the same error.

One of the plugins I had included, guard-bundler, was locking the guard version at 1.4.0, while the latest version of guard is 2.0.5. Removing that plugin fixed the error. Don't forget to remove the guard-bundler code from your guard file.

Im guessing that your guard gem is installed as a system gem. Put it in your gem file and run it with bundle exec.

There is also a dependency conflict between guard and better_errors on coderay. I pinned it at 1.0.5 to get them both installed. I haven't tested any functionality related to coderay to see if that version causes problems for better_errors.

gem 'coderay', '~> 1.0.5'

like image 63
Jon Hart Avatar answered Nov 11 '22 14:11

Jon Hart


I had a similar problem with my rails 3.2.13 app.

The confusing part was that I did not have gem 'guard' in my Gemfile, but the gem was obviously a dependency of the following:

gem 'guard-rspec'
gem 'guard-livereload'
gem 'guard-cucumber'

everything worked until a recent bundle update, which brought in a much newer version of listen, one of guard's dependencies, while guard itself was held back (not sure why). So the error you saw was guard trying to invoke a class that no longer exists in listen.

The problem was solved by explicitly adding the current version of guard to Gemfile:

gem 'guard', '>=2.1.0'

and of course re-bundling.

like image 9
Giuseppe Avatar answered Nov 11 '22 16:11

Giuseppe