Spork error with bundle exec?

Deadly 提交于 2019-12-11 10:28:12

问题


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.


回答1:


In your Gemfile you can specify:

gem 'spork', :version => 0.8.5

Also you might wanna delete newer spork:

gem uninstall spork -v=0.9.0.rc8



回答2:


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 then RubyGems gets activated and looks for an appropriate version. But this bypasses the specified version from the Gemfile that the bundler would use. Only when "bundle exec spork" is used, the bundler can look up the version from the Gemfile. 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.



来源:https://stackoverflow.com/questions/7218262/spork-error-with-bundle-exec

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!