NoMethodError: undefined method `spec' for nil:NilClass - active_utils, factory_girl and more gems failing

你离开我真会死。 提交于 2020-12-30 07:59:22

问题


Out of nowhere, and without changing anything, I've started getting this error (and so did other people on the team).

This is happening for some gems (the ones specifying a git branch) and is only happening when we recreate the environment (in vagrant). We didn't change anything.

Any ideas? More info follows:

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.
  • Running "gem install active_utils -v '2.0.0'" works but bundle always fails.
  • Cleared gem cache, but didn't help

Seems like it's all entries in Gemfile specifying a branch that started failing.

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"

回答1:


So, turns out this was caused because of a recent upgrade to RubyGems. Forcing a previous version worked.

gem update --system 2.4.8



回答2:


While there's already an accepted answer, I ran into the same problem.

Ultimately, the cause was I was using an outdated bundler version and updating to the latest version fixed it. More info on the bug from here: https://github.com/bundler/bundler/issues/3560

The bug happens prior to bundler version 1.9.3.

You can update bundler by running gem install bundler and then deleting the older bundler version via gem uninstall bundler -v old.bundler.version

If you're using rvm, I recommend installing this on the global gemset of your current ruby version by running rvm use @global before doing the install.



来源:https://stackoverflow.com/questions/33733476/nomethoderror-undefined-method-spec-for-nilnilclass-active-utils-factory

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