julienbourdeau / debugbar

Powerful devtools for Ruby on Rails. Inspired by the Laravel Debugbar.
https://debugbar.dev
MIT License
487 stars 8 forks source link

Installation error TagHelper #2

Closed benbagley closed 9 months ago

benbagley commented 9 months ago

Ruby version: 3.2.2 Rails version: 7.1.2

This gem has some incredible potential, very much looking forward to using this.

I went through the installation steps and when running the server I got the following error.

uninitialized constant Debugbar::TagHelpers (NameError)

Here is the full error output:

/Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/debugbar-0.1.2/lib/debugbar/engine.rb:33:in `block (2 levels) in <class:Engine>': uninitialized constant Debugbar::TagHelpers (NameError)

        include Debugbar::TagHelpers
                        ^^^^^^^^^^^^
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.1.2/lib/active_support/lazy_load_hooks.rb:97:in `class_eval'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.1.2/lib/active_support/lazy_load_hooks.rb:97:in `block in execute_hook'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.1.2/lib/active_support/lazy_load_hooks.rb:87:in `with_execution_control'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.1.2/lib/active_support/lazy_load_hooks.rb:92:in `execute_hook'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.1.2/lib/active_support/lazy_load_hooks.rb:62:in `block in on_load'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.1.2/lib/active_support/lazy_load_hooks.rb:61:in `each'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.1.2/lib/active_support/lazy_load_hooks.rb:61:in `on_load'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/debugbar-0.1.2/lib/debugbar/engine.rb:32:in `block in <class:Engine>'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.2/lib/rails/initializable.rb:32:in `instance_exec'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.2/lib/rails/initializable.rb:32:in `run'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.2/lib/rails/initializable.rb:61:in `block in run_initializers'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/tsort.rb:228:in `block in tsort_each'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/tsort.rb:431:in `each_strongly_connected_component_from'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/tsort.rb:349:in `block in each_strongly_connected_component'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `each'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `call'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/tsort.rb:347:in `each_strongly_connected_component'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/tsort.rb:226:in `tsort_each'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/tsort.rb:205:in `tsort_each'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.2/lib/rails/initializable.rb:60:in `run_initializers'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.2/lib/rails/application.rb:423:in `initialize!'
    from /Users/benbagley/code/psisuk-rails/config/environment.rb:7:in `<main>'
    from config.ru:5:in `require_relative'
    from config.ru:5:in `block in <main>'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rack-3.0.8/lib/rack/builder.rb:103:in `eval'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rack-3.0.8/lib/rack/builder.rb:103:in `new_from_string'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rack-3.0.8/lib/rack/builder.rb:94:in `load_file'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rack-3.0.8/lib/rack/builder.rb:64:in `parse_file'
    from /Users/benbagley/.asdf/installs/ruby/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/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rackup-2.1.0/lib/rackup/server.rb:263:in `app'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/rackup-2.1.0/lib/rackup/server.rb:424:in `wrapped_app'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.2/lib/rails/commands/server/server_command.rb:76:in `log_to_stdout'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.2/lib/rails/commands/server/server_command.rb:36:in `start'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.2/lib/rails/commands/server/server_command.rb:145:in `block in perform'
    from <internal:kernel>:90:in `tap'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.2/lib/rails/commands/server/server_command.rb:136:in `perform'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.0/lib/thor/command.rb:28:in `run'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.2/lib/rails/command/base.rb:178:in `invoke_command'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.2/lib/rails/command/base.rb:73:in `perform'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.2/lib/rails/command.rb:71:in `block in invoke'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.2/lib/rails/command.rb:149:in `with_argv'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.2/lib/rails/command.rb:69:in `invoke'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.1.2/lib/rails/commands.rb:18:in `<main>'
    from <internal:/Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
    from <internal:/Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
    from /Users/benbagley/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/bootsnap-1.17.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
    from bin/rails:6:in `<main>'

The engine is mounted as shown in the installation guide + the rendering in the debugbar with the erb helper.

ismarsantos commented 9 months ago

Same problem here.

giovapanasiti commented 9 months ago

Same here with rails 7.0.8 and ruby 3.3.0

bjarkevad commented 9 months ago

Same issue here, Rails 7.1., Ruby 3.3.0. Really looking forward to using this Gem, seems super useful!

MaximeBranger commented 9 months ago

Same issue Rails 7.1.3 and ruby 3.2.2.

julienbourdeau commented 9 months ago

Sorry about that! I'll have a look this weekend. I must have missed something about auto loading.

Do you mind sharing your config/environment.rb? 🙏

jathayde commented 9 months ago

Seeing the same with Ruby 3.3.0 and Rails 7.1.3

config/environment.rb is simple:

# Load the Rails application.
require_relative "application"

# Initialize the Rails application.
Rails.application.initialize!
ActiveRecord::SchemaDumper.ignore_tables = ["spatial_ref_sys"]

Do you need the full development.rb?

benbagley commented 9 months ago

Apologies @julienbourdeau here is my environment.rb

# frozen_string_literal: true

# Load the Rails application.
require_relative "application"

# Initialize the Rails application.
Rails.application.initialize!

Here is my development.rb

# frozen_string_literal: true

require "active_support/core_ext/integer/time"

Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  # In the development environment your application's code is reloaded any time
  # it changes. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.enable_reloading = true

  # Do not eager load code on boot.
  config.eager_load = false

  # Show full error reports.
  config.consider_all_requests_local = true

  # Enable server timing
  config.server_timing = true

  # Enable/disable caching. By default caching is disabled.
  # Run rails dev:cache to toggle caching.
  if Rails.root.join("tmp/caching-dev.txt").exist?
    config.action_controller.perform_caching = true
    config.action_controller.enable_fragment_cache_logging = true

    config.cache_store = :memory_store
    config.public_file_server.headers = {
      "Cache-Control" => "public, max-age=#{2.days.to_i}",
    }
  else
    config.action_controller.perform_caching = false

    config.cache_store = :null_store
  end

  # Store uploaded files on the local file system (see config/storage.yml for options).
  config.active_storage.service = :local

  # Don't care if the mailer can't send.
  config.action_mailer.raise_delivery_errors = false

  config.action_mailer.perform_caching = false

  # Print deprecation notices to the Rails logger.
  config.active_support.deprecation = :log

  # Raise exceptions for disallowed deprecations.
  config.active_support.disallowed_deprecation = :raise

  # Tell Active Support which deprecation messages to disallow.
  config.active_support.disallowed_deprecation_warnings = []

  # Raise an error on page load if there are pending migrations.
  config.active_record.migration_error = :page_load

  # Highlight code that triggered database queries in logs.
  config.active_record.verbose_query_logs = true

  # Highlight code that enqueued background job in logs.
  config.active_job.verbose_enqueue_logs = true

  # Suppress logger output for asset requests.
  config.assets.quiet = true

  # Raises error for missing translations.
  # config.i18n.raise_on_missing_translations = true

  # Annotate rendered view with file names.
  # config.action_view.annotate_rendered_view_with_filenames = true

  # Uncomment if you wish to allow Action Cable access from any origin.
  # config.action_cable.disable_request_forgery_protection = true

  # Raise error when a before_action's only/except options reference missing actions
  config.action_controller.raise_on_missing_callback_actions = true

  # mailtrap
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    user_name: "xxxxxx",
    password: "xxxxxx",
    address: "sandbox.smtp.mailtrap.io",
    host: "sandbox.smtp.mailtrap.io",
    port: "2525",
    authentication: :login,
  }

  # set action mailer default url options
  config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
end
julienbourdeau commented 9 months ago

Thanks! Nothing out of the ordinary.

As far as I understand, once the engine is required, the dir app/helpers should be added to the autoloader. https://guides.rubyonrails.org/autoloading_and_reloading_constants.html#autoloading-and-engines

I also added bootsnap to my demo app to be closer to yours.

I'd like to figure out what's going but in the meantime, I might just require explicitely all classes/modules in the app folder 🤔

Do you mind running this please? 🙏

bin/rails runner 'pp Rails.autoloaders.zeitwerk_enabled?, ActiveSupport::Dependencies.autoload_paths'

This is what I get:

$ bin/rails runner 'pp Rails.autoloaders.zeitwerk_enabled?, ActiveSupport::Dependencies.autoload_paths'
true
["/Users/julien.bourdeau/Personal/rails/demo_app/lib",
 "/Users/julien.bourdeau/Personal/rails/demo_app/app/channels",
 "/Users/julien.bourdeau/Personal/rails/demo_app/app/controllers",
 "/Users/julien.bourdeau/Personal/rails/demo_app/app/controllers/concerns",
 "/Users/julien.bourdeau/Personal/rails/demo_app/app/helpers",
 "/Users/julien.bourdeau/Personal/rails/demo_app/app/jobs",
 "/Users/julien.bourdeau/Personal/rails/demo_app/app/mailers",
 "/Users/julien.bourdeau/Personal/rails/demo_app/app/models",
 "/Users/julien.bourdeau/Personal/rails/demo_app/app/models/concerns",
 "/Users/julien.bourdeau/Personal/debugbar/debugbar/app/channels",
 "/Users/julien.bourdeau/Personal/debugbar/debugbar/app/controllers",
 "/Users/julien.bourdeau/Personal/debugbar/debugbar/app/helpers",
 "/Users/julien.bourdeau/Personal/debugbar/debugbar/app/models",
 "/Users/julien.bourdeau/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionmailbox-7.1.3/app/controllers",
 "/Users/julien.bourdeau/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionmailbox-7.1.3/app/jobs",
 "/Users/julien.bourdeau/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionmailbox-7.1.3/app/models",
 "/Users/julien.bourdeau/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activestorage-7.1.3/app/controllers",
 "/Users/julien.bourdeau/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activestorage-7.1.3/app/controllers/concerns",
 "/Users/julien.bourdeau/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activestorage-7.1.3/app/jobs",
 "/Users/julien.bourdeau/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activestorage-7.1.3/app/models"]
julienbourdeau commented 9 months ago

Can anyone please try v0.1.3 and see if it resolved the issue 🙏

benbagley commented 9 months ago

Hi @julienbourdeau 0.1.13 works CleanShot 2024-02-18 at 8  59 50@2x

Let me know if you still need the above command ran?

benbagley commented 9 months ago

Not sure if this is another thing (after 0.1.13 install) CleanShot 2024-02-18 at 9  02 37@2x

Looks to have an image with ActiveStorage images

Same goes for signing in with devise looks to pinpoint where the issue is though CleanShot 2024-02-18 at 9  07 43@2x

julienbourdeau commented 9 months ago

Good news for TagHelpers!

The other one is a different error, I'm fixing it here #11 🙈