捆绑执行时 Spork 错误?

发布于 2024-12-01 18:28:15 字数 627 浏览 2 评论 0原文

每当我运行 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 updategem 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

弱骨蛰伏 2024-12-08 18:28:15

在 Gemfile 中,您可以指定:

gem 'spork', :version => 0.8.5

另外,您可能想删除较新的 spork:

gem uninstall spork -v=0.9.0.rc8

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
我的痛♀有谁懂 2024-12-08 18:28:15

也许您的问题已经解决了(我认为),但我在过去几天遇到了类似的问题并找到了此错误的原因。它与使用捆绑器时所有所需 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 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文