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

LoadError: cannot load such file #74

Closed
mickael-palma-argus opened this issue Aug 23, 2019 · 4 comments
Closed

LoadError: cannot load such file #74

mickael-palma-argus opened this issue Aug 23, 2019 · 4 comments

Comments

@mickael-palma-argus
Copy link

Hi,

I am trying to upgrade from Rails 6 beta 3 to finale but something changed.

My app uses this gem https://github.com/mickael-palma-argus/activestorage-openstack which also uses Zeitwerk (you helped me with it a few months back).

Everything worked fined with 6.0.0.beta3 but now when I start my app with the final 6.0.0 I have this error:

2019-08-23T10:05:47.295556+00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rb`
2019-08-23T10:05:49.585702+00:00 app[web.1]: Puma starting in single mode...
2019-08-23T10:05:49.585722+00:00 app[web.1]: * Version 4.1.0 (ruby 2.6.3-p62), codename: Fourth and One
2019-08-23T10:05:49.585724+00:00 app[web.1]: * Min threads: 20, max threads: 20
2019-08-23T10:05:49.585732+00:00 app[web.1]: * Environment: staging
2019-08-23T10:05:51.139101+00:00 heroku[web.1]: State changed from starting to crashed
2019-08-23T10:05:51.121376+00:00 heroku[web.1]: Process exited with status 1
2019-08-23T10:05:51.062382+00:00 app[web.1]: ! Unable to load application: NameError: expected file /usr/local/bundle/gems/activestorage_openstack-0.1.5/lib/active_storage/openstack/version.rb to define constant ActiveStorage::Openstack::Version, but didn't
2019-08-23T10:05:51.062493+00:00 app[web.1]: bundler: failed to load command: puma (/usr/local/bundle/bin/puma)
2019-08-23T10:05:51.062543+00:00 app[web.1]: NameError: expected file /usr/local/bundle/gems/activestorage_openstack-0.1.5/lib/active_storage/openstack/version.rb to define constant ActiveStorage::Openstack::Version, but didn't
2019-08-23T10:05:51.062545+00:00 app[web.1]: /usr/local/bundle/gems/zeitwerk-2.1.9/lib/zeitwerk/loader/callbacks.rb:17:in `on_file_autoloaded'
2019-08-23T10:05:51.062546+00:00 app[web.1]: /usr/local/bundle/gems/zeitwerk-2.1.9/lib/zeitwerk/kernel.rb:17:in `block in require'
2019-08-23T10:05:51.062548+00:00 app[web.1]: /usr/local/bundle/gems/zeitwerk-2.1.9/lib/zeitwerk/kernel.rb:16:in `tap'
2019-08-23T10:05:51.062549+00:00 app[web.1]: /usr/local/bundle/gems/zeitwerk-2.1.9/lib/zeitwerk/kernel.rb:16:in `require'
2019-08-23T10:05:51.062550+00:00 app[web.1]: /usr/local/bundle/gems/zeitwerk-2.1.9/lib/zeitwerk/loader.rb:351:in `const_get'
2019-08-23T10:05:51.062552+00:00 app[web.1]: /usr/local/bundle/gems/zeitwerk-2.1.9/lib/zeitwerk/loader.rb:351:in `block (2 levels) in eager_load'
2019-08-23T10:05:51.062553+00:00 app[web.1]: /usr/local/bundle/gems/zeitwerk-2.1.9/lib/zeitwerk/loader.rb:662:in `block in ls'
2019-08-23T10:05:51.062554+00:00 app[web.1]: /usr/local/bundle/gems/zeitwerk-2.1.9/lib/zeitwerk/loader.rb:659:in `foreach'
2019-08-23T10:05:51.062556+00:00 app[web.1]: /usr/local/bundle/gems/zeitwerk-2.1.9/lib/zeitwerk/loader.rb:659:in `ls'
2019-08-23T10:05:51.062557+00:00 app[web.1]: /usr/local/bundle/gems/zeitwerk-2.1.9/lib/zeitwerk/loader.rb:346:in `block in eager_load'
2019-08-23T10:05:51.062559+00:00 app[web.1]: /usr/local/bundle/gems/zeitwerk-2.1.9/lib/zeitwerk/loader.rb:338:in `synchronize'
2019-08-23T10:05:51.062560+00:00 app[web.1]: /usr/local/bundle/gems/zeitwerk-2.1.9/lib/zeitwerk/loader.rb:338:in `eager_load'
2019-08-23T10:05:51.062561+00:00 app[web.1]: /usr/local/bundle/gems/zeitwerk-2.1.9/lib/zeitwerk/loader.rb:449:in `each'
2019-08-23T10:05:51.062563+00:00 app[web.1]: /usr/local/bundle/gems/zeitwerk-2.1.9/lib/zeitwerk/loader.rb:449:in `eager_load_all'
2019-08-23T10:05:51.062564+00:00 app[web.1]: /usr/local/bundle/gems/railties-6.0.0/lib/rails/application/finisher.rb:122:in `block in <module:Finisher>'
2019-08-23T10:05:51.062565+00:00 app[web.1]: /usr/local/bundle/gems/railties-6.0.0/lib/rails/initializable.rb:32:in `instance_exec'
2019-08-23T10:05:51.062566+00:00 app[web.1]: /usr/local/bundle/gems/railties-6.0.0/lib/rails/initializable.rb:32:in `run'
2019-08-23T10:05:51.062568+00:00 app[web.1]: /usr/local/bundle/gems/railties-6.0.0/lib/rails/initializable.rb:61:in `block in run_initializers'
2019-08-23T10:05:51.062569+00:00 app[web.1]: /usr/local/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
2019-08-23T10:05:51.062570+00:00 app[web.1]: /usr/local/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
2019-08-23T10:05:51.062571+00:00 app[web.1]: /usr/local/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
2019-08-23T10:05:51.062573+00:00 app[web.1]: /usr/local/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
2019-08-23T10:05:51.062574+00:00 app[web.1]: /usr/local/lib/ruby/2.6.0/tsort.rb:347:in `each'
2019-08-23T10:05:51.062575+00:00 app[web.1]: /usr/local/lib/ruby/2.6.0/tsort.rb:347:in `call'
2019-08-23T10:05:51.062577+00:00 app[web.1]: /usr/local/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
2019-08-23T10:05:51.062578+00:00 app[web.1]: /usr/local/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
2019-08-23T10:05:51.062579+00:00 app[web.1]: /usr/local/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
2019-08-23T10:05:51.062581+00:00 app[web.1]: /usr/local/bundle/gems/railties-6.0.0/lib/rails/initializable.rb:60:in `run_initializers'
2019-08-23T10:05:51.062582+00:00 app[web.1]: /usr/local/bundle/gems/railties-6.0.0/lib/rails/application.rb:363:in `initialize!'
2019-08-23T10:05:51.062583+00:00 app[web.1]: /app/config/environment.rb:7:in `<top (required)>'
2019-08-23T10:05:51.062585+00:00 app[web.1]: config.ru:5:in `require_relative'
2019-08-23T10:05:51.062586+00:00 app[web.1]: config.ru:5:in `block in <main>'
2019-08-23T10:05:51.062587+00:00 app[web.1]: /usr/local/bundle/gems/rack-2.0.7/lib/rack/builder.rb:55:in `instance_eval'
2019-08-23T10:05:51.062588+00:00 app[web.1]: /usr/local/bundle/gems/rack-2.0.7/lib/rack/builder.rb:55:in `initialize'
2019-08-23T10:05:51.062590+00:00 app[web.1]: config.ru:in `new'
2019-08-23T10:05:51.062591+00:00 app[web.1]: config.ru:in `<main>'
2019-08-23T10:05:51.062592+00:00 app[web.1]: /usr/local/bundle/gems/rack-2.0.7/lib/rack/builder.rb:49:in `eval'
2019-08-23T10:05:51.062594+00:00 app[web.1]: /usr/local/bundle/gems/rack-2.0.7/lib/rack/builder.rb:49:in `new_from_string'
2019-08-23T10:05:51.062595+00:00 app[web.1]: /usr/local/bundle/gems/rack-2.0.7/lib/rack/builder.rb:40:in `parse_file'
2019-08-23T10:05:51.062596+00:00 app[web.1]: /usr/local/bundle/gems/puma-4.1.0/lib/puma/configuration.rb:321:in `load_rackup'
2019-08-23T10:05:51.062598+00:00 app[web.1]: /usr/local/bundle/gems/puma-4.1.0/lib/puma/configuration.rb:246:in `app'
2019-08-23T10:05:51.062599+00:00 app[web.1]: /usr/local/bundle/gems/puma-4.1.0/lib/puma/runner.rb:148:in `load_and_bind'
2019-08-23T10:05:51.062600+00:00 app[web.1]: /usr/local/bundle/gems/puma-4.1.0/lib/puma/single.rb:98:in `run'
2019-08-23T10:05:51.062601+00:00 app[web.1]: /usr/local/bundle/gems/puma-4.1.0/lib/puma/launcher.rb:188:in `run'
2019-08-23T10:05:51.062603+00:00 app[web.1]: /usr/local/bundle/gems/puma-4.1.0/lib/puma/cli.rb:80:in `run'
2019-08-23T10:05:51.062604+00:00 app[web.1]: /usr/local/bundle/gems/puma-4.1.0/bin/puma:10:in `<top (required)>'
2019-08-23T10:05:51.062605+00:00 app[web.1]: /usr/local/bundle/bin/puma:23:in `load'
2019-08-23T10:05:51.062609+00:00 app[web.1]: /usr/local/bundle/bin/puma:23:in `<top (required)>'
@casperisfine
Copy link
Contributor

This is because of how the GemInflector is implemented: https://github.com/fxn/zeitwerk/blob/757dd734340024e487bd9678dcf80a567064bfdc/lib/zeitwerk/gem_inflector.rb

It doesn't handle sub namespaces, so you'll have to setup a custom one.

@casperisfine
Copy link
Contributor

Oh, I see you already started that: https://github.com/argus-api-team/activestorage-openstack/blob/c404abc9e7d161cfa50f0d9ab29e4550d8cc2389/lib/support/zeitwerk.rb#L8

So just add another rule for when 'version' then 'VERSION'

@casperisfine
Copy link
Contributor

Also, another unrelated advice, you should namespace that inflector class, because right now you are defining it at the top level, and CustomInflector is relatively likely to be defined by your users.

@mickael-palma-argus
Copy link
Author

I understand, thank you for your quick feedback.

I will fix the gem accordingly.

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants