avo icon indicating copy to clipboard operation
avo copied to clipboard

Unable to launch Avo

Open mvondoyannick opened this issue 2 years ago • 2 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

mvondoyannick avatar Jul 26 '22 04:07 mvondoyannick

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?

adrianthedev avatar Jul 26 '22 09:07 adrianthedev

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

github-actions[bot] avatar Aug 11 '22 03:08 github-actions[bot]

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?

kbighorse avatar Aug 24 '22 07:08 kbighorse

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

kbighorse avatar Aug 24 '22 07:08 kbighorse

@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?

adrianthedev avatar Aug 24 '22 07:08 adrianthedev

  • rails 6.1.6.1
  • avo 2.13.1
  • ruby 3.0.4
  • existing
  • not to my knowledge

kbighorse avatar Aug 24 '22 07:08 kbighorse

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

kbighorse avatar Aug 24 '22 07:08 kbighorse

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

https://whereby.com/adrianthedev

adrianthedev avatar Aug 24 '22 08:08 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.

adrianthedev avatar Aug 24 '22 08:08 adrianthedev

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.

adrianthedev avatar Aug 24 '22 11:08 adrianthedev

codebase search for 'autoloader' turns up empty :/

kbighorse avatar Aug 25 '22 06:08 kbighorse

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

adrianthedev avatar Aug 25 '22 06:08 adrianthedev

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.

kbighorse avatar Aug 25 '22 06:08 kbighorse

Bingo!!!

Thanks for looking into this and fixing the issue.

I'll add this to the docs too.

adrianthedev avatar Aug 25 '22 06:08 adrianthedev

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.

kbighorse avatar Aug 25 '22 06:08 kbighorse

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

kbighorse avatar Aug 25 '22 07:08 kbighorse

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

kbighorse avatar Aug 25 '22 07:08 kbighorse

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')]

kbighorse avatar Aug 25 '22 08:08 kbighorse

see: https://stackoverflow.com/questions/72266610/zeitwerk-doesnt-requires-lib-classes-properly-in-rails-6-1-6

kbighorse avatar Aug 25 '22 08:08 kbighorse

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

adrianthedev avatar Aug 25 '22 08:08 adrianthedev

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

github-actions[bot] avatar Sep 10 '22 04:09 github-actions[bot]