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

Uninitialized constant error on fresh install #16

Closed
siddhartharun opened this issue Feb 7, 2024 · 13 comments · Fixed by #19
Closed

Uninitialized constant error on fresh install #16

siddhartharun opened this issue Feb 7, 2024 · 13 comments · Fixed by #19

Comments

@siddhartharun
Copy link

Receiving the following error while trying to start my rails server — uninitialized constant HotwireCombobox::Helper (NameError)

Currently running Rails 7.1.1 / Ruby 3.2.2
Turbo and Hotwire are installed.

@josefarias
Copy link
Owner

Thanks @siddhartharun! Does it show a stacktrace as well? Seeing that would be helpful

@siddhartharun
Copy link
Author

Here you go!

/Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/hotwire_combobox-0.1.29/lib/hotwire_combobox/engine.rb:7:in `block (2 levels) in <class:Engine>': uninitialized constant HotwireCombobox::Helper (NameError)

        include HotwireCombobox::Helper
                               ^^^^^^^^
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.1.3/lib/active_support/lazy_load_hooks.rb:97:in `class_eval'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.1.3/lib/active_support/lazy_load_hooks.rb:97:in `block in execute_hook'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.1.3/lib/active_support/lazy_load_hooks.rb:87:in `with_execution_control'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.1.3/lib/active_support/lazy_load_hooks.rb:92:in `execute_hook'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.1.3/lib/active_support/lazy_load_hooks.rb:62:in `block in on_load'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.1.3/lib/active_support/lazy_load_hooks.rb:61:in `each'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.1.3/lib/active_support/lazy_load_hooks.rb:61:in `on_load'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/hotwire_combobox-0.1.29/lib/hotwire_combobox/engine.rb:6:in `block in <class:Engine>'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3/lib/rails/initializable.rb:32:in `instance_exec'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3/lib/rails/initializable.rb:32:in `run'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3/lib/rails/initializable.rb:61:in `block in run_initializers'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:228:in `block in tsort_each'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:431:in `each_strongly_connected_component_from'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:349:in `block in each_strongly_connected_component'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `each'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `call'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `each_strongly_connected_component'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:226:in `tsort_each'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/3.2.0/tsort.rb:205:in `tsort_each'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3/lib/rails/initializable.rb:60:in `run_initializers'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3/lib/rails/application.rb:426:in `initialize!'
	from /Users/sdrn/Developer/gist/config/environment.rb:5:in `<main>'
	from config.ru:3:in `require_relative'
	from config.ru:3:in `block in <main>'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rack-3.0.9/lib/rack/builder.rb:103:in `eval'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rack-3.0.9/lib/rack/builder.rb:103:in `new_from_string'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rack-3.0.9/lib/rack/builder.rb:94:in `load_file'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rack-3.0.9/lib/rack/builder.rb:64:in `parse_file'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rackup-2.1.0/lib/rackup/server.rb:354:in `build_app_and_options_from_config'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rackup-2.1.0/lib/rackup/server.rb:263:in `app'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rackup-2.1.0/lib/rackup/server.rb:424:in `wrapped_app'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3/lib/rails/commands/server/server_command.rb:76:in `log_to_stdout'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3/lib/rails/commands/server/server_command.rb:36:in `start'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3/lib/rails/commands/server/server_command.rb:145:in `block in perform'
	from <internal:kernel>:90:in `tap'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3/lib/rails/commands/server/server_command.rb:136:in `perform'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.0/lib/thor/command.rb:28:in `run'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3/lib/rails/command/base.rb:178:in `invoke_command'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3/lib/rails/command/base.rb:73:in `perform'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3/lib/rails/command.rb:71:in `block in invoke'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3/lib/rails/command.rb:149:in `with_argv'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3/lib/rails/command.rb:69:in `invoke'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.3/lib/rails/commands.rb:18:in `<main>'
	from <internal:/Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
	from <internal:/Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
	from /Users/sdrn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
	from bin/rails:4:in `<main>'

@josefarias
Copy link
Owner

Thanks!

I wonder if it's a Rails 7.1.1 thing. The docs app uses 7.1.3 with Ruby 3.2.2. You might want to give that a try if upgrading is possible.

I'll take a look at this tomorrow, though.

@josefarias
Copy link
Owner

Ah but the stacktrace shows 7.1.3 so maybe not. I'll take a closer look tomorrow.

@siddhartharun
Copy link
Author

Yup, I just upgraded to 7.1.3 and still got the same error. No rush, and thank you for putting together this amazing gem! Can't wait to use this in my projects.

@pranavbabu
Copy link
Contributor

I have same issue

@adrianthedev
Copy link

Me too!
I'm trying to add it as a field to https://github.com/avo-hq/avo

@pranavbabu
Copy link
Contributor

pranavbabu commented Feb 7, 2024

If it helps I noticed that the first thing that required in hotwire_combobox.rb is engine.rb and inside engine.rb it has include Helper and this Helper is using methods from hotwire_combobox.rb which is not initiated yet. I tried to solve Uninitialized constant issue by requiring helper file at engine.rb and got next error that bypass_convenience_methods? method is not implemented on HotwireCombobox module.

@josefarias
Copy link
Owner

Me too!

I'm trying to add it as a field to https://github.com/avo-hq/avo

Thanks! This is helpful since I can clone the repo and reproduce locally.

I'll try doing that in a bit. Taking a look shortly!

@adrianthedev
Copy link

I don't have a PR up yet. It might be a bit difficult to reproduce.

@josefarias
Copy link
Owner

josefarias commented Feb 7, 2024

@siddhartharun @pranavbabu @adrianthedev could I get you to try v0.1.30 (just published) and see if that solves the problem, please? I'll reopen if not.

@adrianthedev I see avo uses sprockets for JS. I haven't tested for that. I think you might need to include the js manually the same way you have to include the css. There's no helper for that yet, though. Please let me know whether or not you run into trouble in that regard so I can know if sprockets is properly supported. Maybe chime in here: #10

@adrianthedev
Copy link

Got it!
I'll let you know about the sprockets integration.
If it were up to me I'd just update to propshaft, but Avo's a gem that others use in their apps so I can't control it.

I'll try it again later this week. I'll keep you posted.

Thanks for the quick response.

@pranavbabu
Copy link
Contributor

pranavbabu commented Feb 8, 2024

@josefarias The problem is solved, thanks for speed ;)

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

Successfully merging a pull request may close this issue.

4 participants