为什么我今天必须在命令前面加上“bundle exec”?

sup*_*000 4 ruby rspec ruby-on-rails bundler

昨天要运行我的测试,我只需要rspec在命令行上运行。

今天在做了 git pull 和等等之后。我收到这个错误

gems/bundler-1.6.2/lib/bundler/runtime.rb:34:in 'block in setup': You have already activated rspec-support 3.0.3, but your Gemfile requires rspec-support 3.0.0. Prepending 'bundle exec' to your command may solve this. (Gem::LoadError)
Run Code Online (Sandbox Code Playgroud)

是的bundle exec rspec,可以运行并运行我的测试。这里“幕后”到底发生了什么?

小智 6

我想在某些时候,rspec-support您的系统中的 gem 已更新。也许你做了一个gem update. 但您的应用程序正在使用版本 3.0.0,这就是出现该消息的原因。您可以使用 更新您的捆绑包bundle update。通常避免版本冲突的推荐方法是使用bundle exec.

参考:

  • 要停止使用bundle exec rake,您可以运行bundle clean --force。此命令将更新您的 Gemfile.lock。 (3认同)