Question

I'm trying to set up Guard on Windows with JRuby and I'm getting this output:

$ guard
You must 'gem install win32console' to use color on Windows
WARNING: You are using Guard outside of Bundler, this is dangerous and could not
 work. Using `bundle exec guard` is safer.
Guard uses Notifu to send notifications.
Guard is now watching at 'C:/Workspace/OE_11/CyberTrack_Rails3'
Guard::RSpec is running, with RSpec 2!

Running all specs
bundler: command not found: rspec
Install missing gem executables with `bundle install`
>

If I just type the command 'rspec', things do work. So what am I missing here?

$ rspec
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m


Finished in 1.39 seconds
←[32m8 examples, 0 failures←[0m

I added the path to rspec.bat to my PATH environment variable.

By the way, I'm working on Windows. On Ubuntu I got everything working in no time...

UPDATE Gemfile:

source 'https://rubygems.org'

gem 'rails', '3.2.2.rc1'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'activerecord-jdbcsqlite3-adapter'

gem 'jruby-openssl'
gem 'json'

group :development do
    gem 'rspec-rails'
    gem 'guard-rspec'
end

group :test do
    gem 'rspec-rails'
    gem 'guard-rspec'
  gem 'capybara', '1.1.2'
  gem 'rb-fchange', '0.0.5'
  gem 'rb-notifu', '0.0.4'
  #gem 'win32console', '1.3.0'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  gem 'therubyrhino'

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug'
Was it helpful?

Solution

I think it's a bundler bug as I get the same error if I run:

bundle exec rspec spec

I manage to make it work commenting and adding some code to guard-rspec source file.

Open file:

C:\jruby-1.6.7\lib\ruby\gems\1.8\gems\guard-rspec-0.6.0\lib\guard\rspec\runner.rb

Obs: Note that this path might be diferent on you machine. Anyway, just go to the source of the guard-rspec gem and open the runner.rb file.

And change the rspec_command to this:

  def rspec_command(paths, options={})
    warn_deprectation(options)

    cmd_parts = []
    cmd_parts << "rvm #{options[:rvm].join(',')} exec" if options[:rvm].is_a?(Array)
    cmd_parts << "bundle exec" if (bundler? && options[:binstubs] == true && options[:bundler] != false) || (bundler? && options[:bundler] != false)
    cmd_parts << "'"
    cmd_parts << rspec_exec(options)
    cmd_parts << options[:cli] if options[:cli]
    cmd_parts << "-f progress" if options[:cli].nil? || !options[:cli].split(/[\s=]/).any? { |w| %w[-f --format].include?(w) }
    #cmd_parts << "-r #{File.dirname(__FILE__)}/formatters/notification_#{rspec_class.downcase}.rb -f Guard::RSpec::Formatter::Notification#{rspec_class}#{rspec_version == 1 ? ":" : " --out "}/dev/null" if options[:notification] != false
    cmd_parts << "--failure-exit-code #{failure_exit_code}" if failure_exit_code_supported?(options)

    cmd_parts << paths.join(' ')
    cmd_parts << "'"

    cmd_parts.join(' ')
  end

The changes I made:

 1. commented on of the lines
 2. Added 2 code line to add "quotes" to the string builder.

It works here, so it should work on your machine as well. I open an issue on bundler https://github.com/carlhuda/bundler/issues/1689 for the issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top