avo-hq/avo

Unable to launch Avo

Closed this issue · 21 comments

Context

Just install Avo to my rails project and when i run rails s i have this error on terminal i have this error undefined method `push_dir' for nil:NilClass (NoMethodError)

/home/dell/.rvm/gems/ruby-3.0.4/gems/avo-2.11.1/lib/avo/engine.rb:33:in `block (2 levels) in <class:Engine>': undefined method `push_dir' for nil:NilClass (NoMethodError)
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/avo-2.11.1/lib/avo/engine.rb:29:in `each'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/avo-2.11.1/lib/avo/engine.rb:29:in `block in <class:Engine>'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/railties-6.0.5.1/lib/rails/initializable.rb:32:in `instance_exec'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/railties-6.0.5.1/lib/rails/initializable.rb:32:in `run'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/railties-6.0.5.1/lib/rails/initializable.rb:61:in `block in run_initializers'
	from /home/dell/.rvm/rubies/ruby-3.0.4/lib/ruby/3.0.0/tsort.rb:228:in `block in tsort_each'
	from /home/dell/.rvm/rubies/ruby-3.0.4/lib/ruby/3.0.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
	from /home/dell/.rvm/rubies/ruby-3.0.4/lib/ruby/3.0.0/tsort.rb:431:in `each_strongly_connected_component_from'
	from /home/dell/.rvm/rubies/ruby-3.0.4/lib/ruby/3.0.0/tsort.rb:349:in `block in each_strongly_connected_component'
	from /home/dell/.rvm/rubies/ruby-3.0.4/lib/ruby/3.0.0/tsort.rb:347:in `each'
	from /home/dell/.rvm/rubies/ruby-3.0.4/lib/ruby/3.0.0/tsort.rb:347:in `call'
	from /home/dell/.rvm/rubies/ruby-3.0.4/lib/ruby/3.0.0/tsort.rb:347:in `each_strongly_connected_component'
	from /home/dell/.rvm/rubies/ruby-3.0.4/lib/ruby/3.0.0/tsort.rb:226:in `tsort_each'
	from /home/dell/.rvm/rubies/ruby-3.0.4/lib/ruby/3.0.0/tsort.rb:205:in `tsort_each'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/railties-6.0.5.1/lib/rails/initializable.rb:60:in `run_initializers'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/railties-6.0.5.1/lib/rails/application.rb:363:in `initialize!'
	from /home/dell/Documents/Projects/Yde/payquick-develop/config/environment.rb:5:in `<main>'
	from config.ru:3:in `require_relative'
	from config.ru:3:in `block in <main>'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/rack-2.2.4/lib/rack/builder.rb:116:in `eval'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/rack-2.2.4/lib/rack/builder.rb:116:in `new_from_string'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/rack-2.2.4/lib/rack/builder.rb:105:in `load_file'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/rack-2.2.4/lib/rack/builder.rb:66:in `parse_file'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/rack-2.2.4/lib/rack/server.rb:349:in `build_app_and_options_from_config'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/rack-2.2.4/lib/rack/server.rb:249:in `app'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/rack-2.2.4/lib/rack/server.rb:422:in `wrapped_app'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/railties-6.0.5.1/lib/rails/commands/server/server_command.rb:77:in `log_to_stdout'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/railties-6.0.5.1/lib/rails/commands/server/server_command.rb:37:in `start'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/railties-6.0.5.1/lib/rails/commands/server/server_command.rb:147:in `block in perform'
	from <internal:kernel>:90:in `tap'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/railties-6.0.5.1/lib/rails/commands/server/server_command.rb:138:in `perform'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/railties-6.0.5.1/lib/rails/command/base.rb:69:in `perform'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/railties-6.0.5.1/lib/rails/command.rb:46:in `invoke'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/railties-6.0.5.1/lib/rails/commands.rb:18:in `<main>'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
	from /home/dell/.rvm/gems/ruby-3.0.4/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
	from bin/rails:4:in `<main>'

System configuration

Avo version: 2.11.1

Rails version: 6.0.5.1

Ruby version: 3.0.4

License type (Community or Pro): Community

Screenshots

avo error

Is this a new installation of Rails or an existing app?

The line this refers to is this one Rails.autoloaders.main.push_dir path.to_s. It suggests that Rails.autoloaders.main is nil, and it should not be that way.

Can you tell (presuming it's not a new app) if you have any setting in your app that overrides the "regular" way of dong autoloading or gem loading?

This issue has been marked as stale because there was no activity for the past 15 days.

I also got this error after successfully generating 1 resource, but failing to generate 2 more. Then seeing it again on server start. What should I confirm re: regular autoloading?

this was on an existing app, not a new one.

@kbighorse can you share the following details please:

  • rails version
  • avo version
  • ruby version
  • new or existing app
  • have you done anything special to the autoloading settings? Or maybe use a gem that touches them?
  • rails 6.1.6.1
  • avo 2.13.1
  • ruby 3.0.4
  • existing
  • not to my knowledge

I can add that my default branch starts up fine, and only my avo topic branch has this issue.

@kbighorse can you jump on to a call now to pair up and troubleshoot together?

https://whereby.com/adrianthedev

It seems you are unavailable now.
Please book a time at your earliest convenience here so we can troubleshoot together.

That's an option for you too @mvondoyannick.

Just to be clear, this issue only happened to you guys as far as I know so I guess it's something related to the app configuration.
That being said, I still want to find out what the issue is and how to fix it.

Hey @mvondoyannick & @kbighorse, can you check if you use the classic mode of autoloading? Check if you have this somewhere config.autoloader = :classic or just config.autoloader.

codebase search for 'autoloader' turns up empty :/

Ok. Then we'll have to do a pairing session to check the code. Please book something for when you're available.

This solved my issue: https://guides.rubyonrails.org/classic_to_zeitwerk_howto.html#applications-running-rails-6-x

# application.rb
config.autoloader = :zeitwerk

My guess is apps that began as Rails 5 and migrated to 6 need to be explicitly set to zeitwerk mode.

Bingo!!!

Thanks for looking into this and fixing the issue.

I'll add this to the docs too.

yikes, I still had in the previous line:

    config.load_defaults 5.1

I think the real solution is actually:

    config.load_defaults 6.1

in my case.

Definitely worth documenting, many more apps like mine will hit this. Thanks for your prompt attention!

For posterity, to confirm you have this issue:

  • throw a byebug statement at the end of your application.rb and then run:
(byebug) config.autoloader
:classic

Also, it appears another consequence of this issue is that previously autoloaded /lib directory now needs to be explicitly autoloaded:

# config/application.rb

config.autoload_paths += Dir[Rails.root.join('lib')]

Thanks for keeping this up to date. I linked the docs to this issue.

This issue has been marked as stale because there was no activity for the past 15 days.