thekompanee / chamber

A surprisingly configurable convention-based approach to managing your application's custom configuration settings.
https://github.com/thekompanee/chamber
MIT License
202 stars 25 forks source link

PP requires a require in `chamber show` #84

Open ttilberg opened 1 week ago

ttilberg commented 1 week ago

Running chamber show executes PP.pp(...). The constant PP is not found. Instead the user receives an uninitialized constant error.

▶ chamber show
/Users/ttilberg/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/chamber-3.1.0/lib/chamber/commands/show.rb:22:in `call': uninitialized constant Chamber::Commands::Show::PP (NameError)

      PP
      ^^
    from /Users/ttilberg/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/chamber-3.1.0/lib/chamber/commands/base.rb:15:in `call'
    from /Users/ttilberg/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/chamber-3.1.0/lib/chamber/binary/runner.rb:78:in `show'
    from /Users/ttilberg/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/thor-1.3.2/lib/thor/command.rb:28:in `run'
    from /Users/ttilberg/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/thor-1.3.2/lib/thor/invocation.rb:127:in `invoke_command'
    from /Users/ttilberg/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/thor-1.3.2/lib/thor.rb:538:in `dispatch'
    from /Users/ttilberg/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/thor-1.3.2/lib/thor/base.rb:584:in `start'
    from /Users/ttilberg/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/chamber-3.1.0/bin/chamber:7:in `<top (required)>'
    from /Users/ttilberg/.asdf/installs/ruby/3.3.5/bin/chamber:25:in `load'
    from /Users/ttilberg/.asdf/installs/ruby/3.3.5/bin/chamber:25:in `<main>'

At first I thought this may be related to recent changes to Ruby's standard lib/default gems, but I've tried running chamber show from a variety of older ruby versions across a variety of OSs. I've tested using macos with the following ruby versions:

  2.7.5
  3.0.6
  3.1.2
  3.2.4
  3.3.5

and Ubuntu 24.04 with Ruby 3.0.3.

I don't think this is related to recent changes related to default gems. It is currently a default gem and hasn't moved recently from what I can tell. https://stdgems.org/pp/

Adding require 'pp' to the top of the show file fixes the constant lookup.

ttilberg commented 1 week ago

I see that a commit from last year removed this require statement: https://github.com/thekompanee/chamber/commit/fe82e96d78e9a6ce0910bcaf6beb67645d13ca76

It was labeled as Chore: Autofix (Safe) 'Lint/RedundantRequireStatement', however it seems to not have been safe afterall.