守卫 gem 错误

Guard gem error

我正在尝试初始化 guard gem 以与 rspec 一起工作,但出现错误。 重复此错误的简单方法 (ruby 2.1.5, rails 4.1.8, Windows 7 x64):

  1. rails 新 sample_app
  2. 在gem文件
  3. 中包含“gem'guard-rspec'”
  4. 捆绑包更新
  5. 捆绑安装
  6. bundle exec guard init rspec

应该这样写:

Writing new Guardfile to /Users/mhartl/rails_projects/sample_app/Guardfile rspec guard added to Guardfile, feel free to edit it

并生成一个Guardfile。 获取输出:

D:\Programming\Projects\Ruby\Rails\sample_app>bundle exec guard init rspec
D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/guard-2.12.2/bin/guard:18:in `spawn': Exec forma
t error - D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/guard-2.12.2/bin/_guard-core (Errno::E
NOEXEC)
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/guard-2.12.2/bin/guard:18:in `ignor
e_interrupts'
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/guard-2.12.2/bin/guard:27:in `<top
(required)>'
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/bin/guard:23:in `load'
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/bin/guard:23:in `<main>'

没有生成文件。 Gemfile(rails new app + guard-rspec):

source 'https://rubygems.org'

gem 'guard-rspec'

gem 'rails', '4.1.8'
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0',          group: :doc

gem 'tzinfo-data', platforms: [:mingw, :mswin]

事实证明,guard 2.12.2 无法正常工作。我不得不从一个版本回滚到另一个版本,最后 2.11.1 工作得很好。所以 gemfile 行看起来像这样:

...
  gem 'guard-rspec'
  gem 'guard', '2.11.1'
...