factory_bot_rails: undefined method `config' for nil:NilClass after upgrading to 6.4.0
Description
After the update to 6.4, when starting my rails app I get:
/home/maraud/.rvm/gems/ruby-3.0.4/gems/railties-7.0.4/lib/rails.rb:47:in configuration’: undefined method config' for nil:NilClass (NoMethodError)
Downgrade to 6.2.X solve the issue
Reproduction Steps
Upgrade factory bot rails to 6.4.0 Try to launch puma
Expected behavior
The rails app should be able to initailize or steps on how to make it work with 6.4 should be provided
Actual behavior
/home/maraud/.rvm/gems/ruby-3.0.4/gems/railties-7.0.4/lib/rails.rb:47:in configuration’: undefined method config' for nil:NilClass (NoMethodError)
System configuration
factory_bot_rails version: 6.4.0 factory_bot version: 6.4.0 rails version: 7.0.4 ruby version: 3.0.4
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 90
- Comments: 16 (1 by maintainers)
Commits related to this issue
- Reject sequence definitions for Active Record primary keys (#419) Alternative to [thoughtbot/factory_bot#1586][] Depends on [thoughtbot/factory_bot#1587][] First, introduce the `FactoryBotRails::... — committed to thoughtbot/factory_bot_rails by seanpdoyle 3 years ago
- Pin factory_bot_rails to 6.3.0 Until https://github.com/thoughtbot/factory_bot_rails/issues/433 is resolved — committed to sul-dlss/sul-requests by jcoyne 3 years ago
- Pin factory_bot_rails to 6.2.0 Until https://github.com/thoughtbot/factory_bot_rails/issues/433 is resolved — committed to sul-dlss/sul-requests by jcoyne 3 years ago
- Pin factory_bot_rails to 6.2.0 Until https://github.com/thoughtbot/factory_bot_rails/issues/433 is resolved — committed to sul-dlss/mise by jcoyne 3 years ago
- Pin factory_bot_rails to 6.2.0 Until https://github.com/thoughtbot/factory_bot_rails/issues/433 is resolved — committed to sul-dlss/exhibits by jcoyne 3 years ago
- Pin factory_bot_rails to 6.2.0 Until https://github.com/thoughtbot/factory_bot_rails/issues/433 is resolved — committed to sul-dlss/earthworks by jcoyne 3 years ago
- Update gems and restrict factory_bot_rails to 6.2 The latest version of factory_bot_rails crashes the app on initialization. I'll remove the restriction once the issue is fixed. https://github.com/th... — committed to DFE-Digital/apply-for-teacher-training by zarembas 3 years ago
- Avoid buggy versions of factory_bot_rails https://github.com/thoughtbot/factory_bot_rails/issues/433 — committed to sciencehistory/kithe by jrochkind 3 years ago
- Avoid buggy versions of factory_bot_rails https://github.com/thoughtbot/factory_bot_rails/issues/433 — committed to sciencehistory/kithe by jrochkind 3 years ago
- Avoid buggy versions of factory_bot_rails https://github.com/thoughtbot/factory_bot_rails/issues/433 — committed to sciencehistory/kithe by jrochkind 3 years ago
- Avoid buggy versions of factory_bot_rails https://github.com/thoughtbot/factory_bot_rails/issues/433 — committed to sciencehistory/kithe by jrochkind 3 years ago
- Avoid buggy versions of factory_bot_rails There's a bug in the latest version of `factory_bot_rails`: https://github.com/thoughtbot/factory_bot_rails/issues/433 There's also a fix that hasn't been m... — committed to bullet-train-co/bullet_train by jagthedrummer 3 years ago
- Avoid buggy versions of factory_bot_rails (#1173) * Avoid buggy versions of factory_bot_rails There's a bug in the latest version of `factory_bot_rails`: https://github.com/thoughtbot/factory_bot... — committed to bullet-train-co/bullet_train by jagthedrummer 3 years ago
- upgraded factory_bot_rails further to address this issue: https://github.com/thoughtbot/factory_bot_rails/issues/433 — committed to Crown-Commercial-Service/DataSubmissionServiceAPI by reemi1510 3 years ago
- Upgrade factory_bot_rails to fix tests Seems to be related to https://github.com/thoughtbot/factory_bot_rails/issues/433 but it only triggered after using flipper — committed to mauriciofierrom/along by mauriciofierrom 2 years ago
- Upgrade factory_bot_rails to fix tests Seems to be related to https://github.com/thoughtbot/factory_bot_rails/issues/433 but it only triggered after using flipper — committed to mauriciofierrom/along by mauriciofierrom 2 years ago
https://github.com/thoughtbot/factory_bot_rails/pull/432 might solve the issue!
Also experiencing this on 6.4.0 with Rails 7.1.2 and Ruby 3.1.4
I’m still getting the
undefined method 'config' for nil:NilClasswithfactory_bot6.4.2andfactory_bot_rails6.4.0. The error is within thefactory_bot_railsgem, so I don’t expect updates tofactory_botto resolve this issue.Also experiencing this on 6.4.0 with Rails 7.0.8 and Ruby 3.2.2.
Workaround is to specify it with
gem 'factory_bot_rails', require: falsein theGemfileand do arequire 'factory_bot_rails'inspec/rails_helper.rbClosing this, as
factory_bot_rails6.4.2 fixed the issue. Please notefactory_bot6.4.2 was released before and has nothing to do with this issue.I can confirm that 6.4.2 has fixed the issue for me that I was seeing in 6.4.0.
@jarl-dk You have to revert to 6.2.0 for things to work again.
Gemfile:
gem 'factory_bot_rails', '~> 6.2.0'fixed it for me. (usinggem "rails", "~> 7.0.4", ">= 7.0.4.3", fyi)I should prob upgrade past 6.4.0 (like said above) and investigate further. Too lazy. Hope this helps 1 person.
I assume this can be closed since https://github.com/thoughtbot/factory_bot_rails/pull/440 got merged and
factory_bot_rails6.4.2 got released?I’m also still having the issue. 6.4.2 did not fix it for me. The highest working version for me is: factory_bot 6.2.1 factory_bot_rails 6.2.0
The work around just make it fail later on the factory internals 🤔
here to be precise https://github.com/thoughtbot/factory_bot_rails/blob/3346305320df35eadae4ac942e44fa7adbbfa574/lib/factory_bot_rails/factory_validator/active_record_validator.rb#L7