捆绑执行时 Spork 错误?
每当我运行 spork
时,都会收到以下错误:
You have already activated spork 0.9.0.rc8, but your Gemfile requires spork 0.8.5. Consider using bundle exec. (Gem::LoadError)
我的 gemfile:
group :development, :test do
gem "rspec"
gem "rspec-rails"
gem "factory_girl_rails"
gem 'spork'
gem 'webrat'
gem 'awesome_print'
gem 'vcr'
gem 'fakeweb'
end
我运行了 bundle update
和 gem update
甚至 gem update --system
但我仍然看到这个错误。运行 bundle exec spork
有效,但我想知道为什么 spork
不起作用以及如何解决此问题。
Whenever I run spork
, I am getting the following error:
You have already activated spork 0.9.0.rc8, but your Gemfile requires spork 0.8.5. Consider using bundle exec. (Gem::LoadError)
my gemfile:
group :development, :test do
gem "rspec"
gem "rspec-rails"
gem "factory_girl_rails"
gem 'spork'
gem 'webrat'
gem 'awesome_print'
gem 'vcr'
gem 'fakeweb'
end
I have ran bundle update
and gem update
and even gem update --system
but I am still seeing this error. running bundle exec spork
works, but I want to know why spork
doesn't and how I can fix this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 Gemfile 中,您可以指定:
另外,您可能想删除较新的 spork:
In your Gemfile you can specify:
Also you might wanna delete newer spork:
也许您的问题已经解决了(我认为),但我在过去几天遇到了类似的问题并找到了此错误的原因。它与使用捆绑器时所有所需 gem 的版本控制有关。当仅提供“
spork
”时,RubyGems
将被激活并查找合适的版本。但这会绕过捆绑程序将使用的 Gemfile 中的指定版本。仅当使用“bundle exec spork
”时,捆绑器才能从Gemfile
中查找版本。在您的情况下,“spork
”指向版本为“0.9.0
”的已安装 gem,而“bundle exec spork
”使用“0.8.5'。
有一个可用的标志(“bundle exec --binstubs”)可以创建一个“
bin
”文件夹(>=bundler 1.0)并将 Gemfile 指定的所有可执行文件放入其中。代替“bundle exec spork”,写“bin/spork
”是有效的。搜索 Yehuda Katz 的“Gem Versioning and Bundler: Doing it Right”,它更详细地解释了所有内容,对我帮助很大。
Maybe your problem is already solved (I would assume), but I faced a similar problem the last few days and found the reason for this error. It has to do with the versioning of all needed gems when using bundler. When only "
spork
" is provided thenRubyGems
gets activated and looks for an appropriate version. But this bypasses the specified version from theGemfile
that the bundler would use. Only when "bundle exec spork
" is used, the bundler can look up the version from theGemfile
. In your case "spork
" points to an installed gem with version '0.9.0
', while "bundle exec spork
" uses '0.8.5
'.There is a flag available ("bundle exec --binstubs") that creates a "
bin
" folder (>= bundler 1.0) and puts all executables specified by the Gemfile into it. Instead of "bundle exec spork" it is valid to write "bin/spork
".Search for "Gem Versioning and Bundler: Doing it Right" by Yehuda Katz, it explains everything in more detail and helped me a lot.