Bundler + Guard + Rspec + Rbenv =“你已经激活了......”

时间:2014-05-12 10:27:17

标签: ruby-on-rails rspec guard rbenv

Guard总是让我烦恼这个问题:

.../gems/bundler-1.6.2/lib/bundler/runtime.rb:34:in `block in setup': You have already activated multi_json 1.10.0, but your Gemfile requires multi_json 1.9.2. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)

我知道我可以bundle updategem uninstall或指定Gemfile中的确切版本。

有没有办法一劳永逸地修复它,所以警卫启动bundle exec rspecbin/rspec(我正在使用rbenv)?我想我在github的某个地方看到了一个补丁,但我现在无法找到它。

更新

这里的记录就是bundle exec发生的事情:

$ bundle exec guard
17:11:07 - INFO - Guard is using TerminalNotifier to send notifications.
17:11:07 - INFO - Guard is using TerminalTitle to send notifications.
17:11:07 - INFO - Guard::RSpec is running
17:11:07 - INFO - Guard is now watching at '/Sites/site'
[1] guard(main)>
17:11:10 - INFO - Run all
17:11:10 - INFO - Running all specs
WARN: Unresolved specs during Gem::Specification.reset:
      rspec-expectations (~> 2.14.0)
      rspec-mocks (~> 2.14.0)
      listen (~> 2.7)
      formatador (>= 0.2.4)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
WARN: Unresolved specs during Gem::Specification.reset:
      debugger-ruby_core_source (~> 1.3.2)
      rb-inotify (>= 0.9)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
.../.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/bundler-1.6.2/lib/bundler/runtime.rb:34:in `block in setup': You have already activated formatador 0.2.5, but your Gemfile requires formatador 0.2.4. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
...

1 个答案:

答案 0 :(得分:6)

所以在潜伏了一段时间后,我稍微修改了Guardfile

在:

guard :rspec do

后:

guard :rspec, cmd: 'bundle exec rspec' do

这一劳永逸地解决了这个问题。