Skip to content

Failed to initialize Rack::CommonLogger #3117

@ninoseki

Description

@ninoseki

Describe the bug

Rack::CommonLogger is failed to initialize because of NameError if Verbose is set as true with:

  • puma v6.2.1
  • rack v3.0.7
  • rackup v2.1.0

Puma config:

Please see the following section.

To Reproduce

# test.rb

require "rack"
require "rackup"
require "rack/handler/puma"

class App
  def initialize
    @rack_static = Rack::Static.new(
      -> { [404, {}, []] },
      root: File.expand_path("./", __dir__),
      urls: ["/"]
    )
  end

  def call(env)
    @rack_static.call(env)
  end
end

app = Rack::Builder.new do
  run App.new
end.to_app

Rackup::Handler::Puma.run(app, Verbose: true)
$ ruby test.rb
/Users/foo/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/puma-6.2.1/lib/rack/handler/puma.rb:35:in `block in config': uninitialized constant Puma::Rack::CommonLogger (NameError)

          app = Rack::CommonLogger.new(app, STDOUT)
                    ^^^^^^^^^^^^^^
        from /Users/foo/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/puma-6.2.1/lib/puma/configuration.rb:195:in `configure'
        from /Users/foo/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/puma-6.2.1/lib/puma/configuration.rb:188:in `initialize'
        from /Users/foo/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/puma-6.2.1/lib/rack/handler/puma.rb:32:in `new'
        from /Users/foo/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/puma-6.2.1/lib/rack/handler/puma.rb:32:in `config'
        from /Users/foo/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/puma-6.2.1/lib/rack/handler/puma.rb:64:in `run'
        from test.rb:25:in `<main>'

Expected behavior

Rack::CommonLogger is initialized without NameError.

Desktop (please complete the following information):

  • OS: Mac
  • Puma Version: 6.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions