【问题标题】:NoMethodError: undefined method `spec' for nil:NilClass - active_utils, factory_girl and more gems failingNoMethodError:nil:NilClass 的未定义方法“规范”-active_utils、factory_girl 和更多 gem 失败
【发布时间】:2016-04-06 21:51:20
【问题描述】:

不知从何而来,并且没有进行任何更改,我开始遇到此错误(团队中的其他人也是如此)。

这发生在某些 gem(指定 git 分支的那些)上,并且仅在我们重新创建环境时发生(在 vagrant 中)。我们没有改变任何东西。

有什么想法吗?更多信息如下:

Using active_utils (2.0.0) from git://github.com/Shopify/active_utils.git (at v2.0.0)
NoMethodError: undefined method `spec' for nil:NilClass
An error occurred while installing active_utils (2.0.0), and Bundler cannot continue.
Make sure that `gem install active_utils -v '2.0.0'` succeeds before bundling.

Using factory_girl (2.6.5) from https://github.com/thoughtbot/factory_girl (at 2.6.x)
NoMethodError: undefined method `spec' for nil:NilClass
An error occurred while installing factory_girl (2.6.5), and Bundler cannot continue.
Make sure that `gem install factory_girl -v '2.6.5'` succeeds before bundling.
  • 运行 "gem install active_utils -v '2.0.0'" 有效,但始终捆绑 失败。
  • 已清除 gem 缓存,但没有帮助

似乎是 Gemfile 中的所有条目都指定了一个开始失败的分支。

gem 'active_utils', :git => 'git://github.com/Shopify/active_utils.git', :branch => 'v2.0.0'
gem "will_paginate", :git => "git://github.com/mislav/will_paginate.git", :branch => "2-3-stable"

【问题讨论】:

    标签: ruby-on-rails rubygems


    【解决方案1】:

    所以,事实证明这是由于最近升级到 RubyGems 造成的。强制使用以前的版本有效。

    gem update --system 2.4.8
    

    【讨论】:

      【解决方案2】:

      虽然已经有一个公认的答案,但我遇到了同样的问题。

      最终,原因是我使用了过时的捆绑程序版本并更新到最新版本修复了它。更多关于这个错误的信息:https://github.com/bundler/bundler/issues/3560

      该错误发生在捆绑程序版本 1.9.3 之前。

      您可以通过运行 gem install bundler 来更新捆绑程序 然后通过gem uninstall bundler -v old.bundler.version删除旧的捆绑器版本

      如果您使用的是 rvm,我建议您在安装前运行 rvm use @global 在当前 ruby​​ 版本的全局 gemset 上安装它。

      【讨论】:

      • 对我来说,这个 bug 只出现在 bundler 版本 1.17.2,它在 1.17.3 中为我修复了
      • 1.9.3 是关键,因为之前所有其他版本的 bundler 都有这个问题。
      • 升级到1.17.3 为我解决了这个问题。
      • 我遇到了同样的问题,我卸载了我的1.9.0 版本并安装了1.9.7 版本。有用!谢谢
      猜你喜欢
      • 1970-01-01
      • 2017-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-31
      • 1970-01-01
      相关资源
      最近更新 更多