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

Application does not boot when also using active_record_extended #2

Closed
dsander opened this issue Aug 28, 2019 · 4 comments
Closed

Application does not boot when also using active_record_extended #2

dsander opened this issue Aug 28, 2019 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@dsander
Copy link

dsander commented Aug 28, 2019

Hi 👋 !

I tried using activerecord-pg_enum on a project which already uses active_record_extended. Since active_record_extended has been in use without issues I am reporting the issue here.

Traceback (most recent call last):
	7: from pg_enum.rb:6:in `<main>'
	6: from /Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/2.6.0/bundler/inline.rb:70:in `gemfile'
	5: from /Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/2.6.0/bundler/runtime.rb:65:in `require'
	4: from /Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/2.6.0/bundler/runtime.rb:65:in `each'
	3: from /Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/2.6.0/bundler/runtime.rb:76:in `block in require'
	2: from /Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/2.6.0/bundler/runtime.rb:76:in `each'
	1: from /Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/2.6.0/bundler/runtime.rb:81:in `block (2 levels) in require'
/Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/2.6.0/bundler/runtime.rb:81:in `require': cannot load such file -- activerecord-pg_enum (LoadError)
	16: from pg_enum.rb:6:in `<main>'
	15: from /Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/2.6.0/bundler/inline.rb:70:in `gemfile'
	14: from /Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/2.6.0/bundler/runtime.rb:65:in `require'
	13: from /Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/2.6.0/bundler/runtime.rb:65:in `each'
	12: from /Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/2.6.0/bundler/runtime.rb:72:in `block in require'
	11: from /Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/2.6.0/bundler/runtime.rb:95:in `rescue in block in require'
	10: from /Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/2.6.0/bundler/runtime.rb:95:in `require'
	 9: from /Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/gems/2.6.0/gems/activerecord-pg_enum-1.0.1/lib/activerecord/pg_enum.rb:1:in `<top (required)>'
	 8: from /Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/gems/2.6.0/gems/activerecord-pg_enum-1.0.1/lib/active_record/pg_enum.rb:4:in `<top (required)>'
	 7: from /Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:42:in `on_load'
	 6: from /Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:42:in `each'
	 5: from /Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:43:in `block in on_load'
	 4: from /Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
	 3: from /Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
	 2: from /Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
	 1: from /Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:71:in `instance_eval'
/Users/dominik/.asdf/installs/ruby/2.6.1/lib/ruby/gems/2.6.0/gems/activerecord-pg_enum-1.0.1/lib/active_record/pg_enum.rb:5:in `block in <top (required)>': uninitialized constant ActiveRecord::PGEnum (NameError)

Reproduction script:

# frozen_string_literal: true

require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"

  git_source(:github) { |repo| "https://github.com/#{repo}.git" }

  gem "rails", "~> 5.2"
  gem 'active_record_extended'
  gem 'activerecord-pg_enum'
  gem "pg"
end

require "active_record"
require "minitest/autorun"
require "logger"
alassek added a commit that referenced this issue Aug 28, 2019
If ActiveRecord has already been loaded when PGEnum is required, you
could experience an uninitialized constant error because the load hook
was executing before the PGEnum module was parsed.

Fixes #2
alassek added a commit that referenced this issue Aug 28, 2019
If ActiveRecord has already been loaded when PGEnum is required, you
could experience an uninitialized constant error because the load hook
was executing before the PGEnum module was parsed.

Fixes #2
alassek added a commit that referenced this issue Aug 28, 2019
If ActiveRecord has already been loaded when PGEnum is required, you
could experience an uninitialized constant error because the load hook
was executing before the PGEnum module was parsed.

Fixes #2
@alassek
Copy link
Owner

alassek commented Aug 28, 2019

Hi there 👋 I'm pretty sure that active_record_extended is actually a red herring here. My hypothesis is that activerecord is being initialized before pgenum gets required, which causes the load hook to run out of sequence.

Could you give the load-order-bug branch a try and let me know if that resolves your problem?

@alassek alassek self-assigned this Aug 28, 2019
@alassek alassek added the bug Something isn't working label Aug 28, 2019
@dsander
Copy link
Author

dsander commented Aug 29, 2019

Thank you, that seems to be working. I already tried moving the ActiveSupport.on_load block but did not think of reversing the require order.

@alassek
Copy link
Owner

alassek commented Aug 29, 2019

Awesome, new release incoming

@dsander
Copy link
Author

dsander commented Aug 30, 2019

Great, thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants