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 7 months ago
- Reactions: 89
- 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 10 months 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 7 months 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 7 months 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 7 months 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 7 months 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 7 months 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 vassyz 7 months ago
- Avoid buggy versions of factory_bot_rails https://github.com/thoughtbot/factory_bot_rails/issues/433 — committed to sciencehistory/kithe by jrochkind 7 months ago
- Avoid buggy versions of factory_bot_rails https://github.com/thoughtbot/factory_bot_rails/issues/433 — committed to sciencehistory/kithe by jrochkind 7 months ago
- Avoid buggy versions of factory_bot_rails https://github.com/thoughtbot/factory_bot_rails/issues/433 — committed to sciencehistory/kithe by jrochkind 7 months ago
- Avoid buggy versions of factory_bot_rails https://github.com/thoughtbot/factory_bot_rails/issues/433 — committed to sciencehistory/kithe by jrochkind 7 months 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 7 months 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 7 months 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:NilClass
withfactory_bot
6.4.2
andfactory_bot_rails
6.4.0
. The error is within thefactory_bot_rails
gem, so I don’t expect updates tofactory_bot
to 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: false
in theGemfile
and do arequire 'factory_bot_rails'
inspec/rails_helper.rb
Closing this, as
factory_bot_rails
6.4.2 fixed the issue. Please notefactory_bot
6.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.
I assume this can be closed since https://github.com/thoughtbot/factory_bot_rails/pull/440 got merged and
factory_bot_rails
6.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
@jarl-dk You have to revert to 6.2.0 for things to work again.
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