Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method `config' for nil:NilClass after upgrading to 6.4.0 #433

Closed
julienchabanon opened this issue Nov 17, 2023 · 16 comments
Closed
Labels

Comments

@julienchabanon
Copy link

julienchabanon commented Nov 17, 2023

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

@julienchabanon
Copy link
Author

#432 might solve the issue!

@sealabcore
Copy link

Also experiencing this on 6.4.0 with Rails 7.1.2 and Ruby 3.1.4

@tagliala
Copy link

Superseeds #426

olleolleolle referenced this issue Nov 20, 2023
Alternative to [thoughtbot/factory_bot#1586][]
Depends on [thoughtbot/factory_bot#1587][]

First, introduce the `FactoryBotRails::FactoryValidator` class to serve
as a generic `factory_bot.compile_factory` event observer.

Throughout the lifecycle of the `FactoryBotRails::Railtie`, afford
various initializers with opportunities to add purpose-built validators
to the instance's internal set.

When `factory_bot.compile_factory` events are published, iterate through
the list of validators and forward along the value of the
[event.payload][] to the validator's `#validate!` method.

Next, introduce the Active Record-specific
`FactoryBotRails::FactoryValidator::ActiveRecordValidator` class. Only
require the module whenever [Active Record's engine is loaded][on_load].

The `ActiveRecordValidator#validate!` method rejects attributes that
define primary key generation logic for `ActiveRecord::Base`
descendants.

In order to test this behavior, add a development dependency on
`sqlite3` and `activerecord`, along with some model and database table
generating helper methods.

[thoughtbot/factory_bot#1586]: thoughtbot/factory_bot#1586
[thoughtbot/factory_bot#1587]: thoughtbot/factory_bot#1587
[event.payload]: module-ActiveSupport::Notifications-label-Subscribers
[on_load]: https://guides.rubyonrails.org/engines.html#avoid-loading-rails-frameworks
jcoyne added a commit to sul-dlss/sul-requests that referenced this issue Nov 20, 2023
jcoyne added a commit to sul-dlss/sul-requests that referenced this issue Nov 20, 2023
jcoyne added a commit to sul-dlss/mise that referenced this issue Nov 20, 2023
jcoyne added a commit to sul-dlss/exhibits that referenced this issue Nov 20, 2023
jcoyne added a commit to sul-dlss/earthworks that referenced this issue Nov 20, 2023
zarembas added a commit to DFE-Digital/apply-for-teacher-training that referenced this issue Nov 21, 2023
The latest version of factory_bot_rails crashes the app on initialization.
I'll remove the restriction once the issue is fixed.
thoughtbot/factory_bot_rails#433

I also updated to the latest version some gems that don't seem to be
picked up by dependabot.
jrochkind added a commit to sciencehistory/kithe that referenced this issue Nov 21, 2023
jrochkind added a commit to sciencehistory/kithe that referenced this issue Nov 21, 2023
jrochkind added a commit to sciencehistory/kithe that referenced this issue Nov 21, 2023
jrochkind added a commit to sciencehistory/kithe that referenced this issue Nov 21, 2023
jagthedrummer added a commit to bullet-train-co/bullet_train that referenced this issue Nov 21, 2023
There's a bug in the latest version of `factory_bot_rails`:
thoughtbot/factory_bot_rails#433

There's also a fix that hasn't been merged or released yet:
thoughtbot/factory_bot_rails#432

I'm setting the `Gemfile` to specifically avoid those buggy versions so
that we can get `depfu` un-blocked with keeping gems up to date.
jagthedrummer added a commit to bullet-train-co/bullet_train that referenced this issue Nov 21, 2023
* Avoid buggy versions of factory_bot_rails

There's a bug in the latest version of `factory_bot_rails`:
thoughtbot/factory_bot_rails#433

There's also a fix that hasn't been merged or released yet:
thoughtbot/factory_bot_rails#432

I'm setting the `Gemfile` to specifically avoid those buggy versions so
that we can get `depfu` un-blocked with keeping gems up to date.

* dang linter
@rnestler
Copy link

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 the Gemfile and do a require 'factory_bot_rails' in spec/rails_helper.rb

@kevinrobayna
Copy link

kevinrobayna commented Nov 22, 2023

The work around just make it fail later on the factory internals 🤔

here to be precise

if for_class < ActiveRecord::Base && for_class.primary_key == attribute.name.to_s

     NoMethodError:
       undefined method `<' for nil:NilClass

@tagliala
Copy link

undefined method `<' for nil:NilClass

should have been tracked down and fixed in #431

@rnestler
Copy link

The work around just make it fail later on the factory internals 🤔

Make sure you updated factory_bot (not factory_bot_rails) to 6.4.2.

@akaspick
Copy link

I'm still getting the undefined method 'config' for nil:NilClass with factory_bot 6.4.2 and factory_bot_rails 6.4.0. The error is within the factory_bot_rails gem, so I don't expect updates to factory_bot to resolve this issue.

@jarl-dk
Copy link

jarl-dk commented Nov 23, 2023

Even experiencing this on 6.3.0 with rails 7.0.x

@akaspick
Copy link

@jarl-dk You have to revert to 6.2.0 for things to work again.

@hirowatari
Copy link

I'm still getting the undefined method 'config' for nil:NilClass with factory_bot 6.4.2 and factory_bot_rails 6.4.0. The error is within the factory_bot_rails gem, so I don't expect updates to factory_bot to resolve this issue.

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

@rnestler
Copy link

I assume this can be closed since #440 got merged and factory_bot_rails 6.4.2 got released?

@CodingItWrong
Copy link

I can confirm that 6.4.2 has fixed the issue for me that I was seeing in 6.4.0.

@neilvcarvalho
Copy link
Member

Closing this, as factory_bot_rails 6.4.2 fixed the issue. Please note factory_bot 6.4.2 was released before and has nothing to do with this issue.

@jonathanphilippou
Copy link

jonathanphilippou commented Dec 1, 2023

Gemfile: gem 'factory_bot_rails', '~> 6.2.0' fixed it for me.
(using gem "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.

@zarembas
Copy link

zarembas commented Dec 1, 2023

@Conturbo the issue got fixed, there's nothing to investigate

reemi1510 added a commit to Crown-Commercial-Service/DataSubmissionServiceAPI that referenced this issue Mar 5, 2024
mauriciofierrom added a commit to mauriciofierrom/along that referenced this issue Jul 4, 2024
Seems to be related to
thoughtbot/factory_bot_rails#433 but it only
triggered after using flipper
mauriciofierrom added a commit to mauriciofierrom/along that referenced this issue Jul 4, 2024
Seems to be related to
thoughtbot/factory_bot_rails#433 but it only
triggered after using flipper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests