flippercloud / flipper

🐬 Beautiful, performant feature flags for Ruby.
https://www.flippercloud.io/docs
MIT License
3.7k stars 413 forks source link

(1.2) uninitialized constant Flipper::CLI::IRB (NameError) #817

Closed manewitz closed 9 months ago

manewitz commented 9 months ago

Excited to check out the 1.2 CLI but running into this error around IRB colorization. flipper --help runs correctly but list, show, enable and disable are giving the same NameError. I'm on Ruby 3.2.2. via asdf. Any ideas?

❯ flipper list
/Users/mikemanewitz/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/flipper-1.2.0/lib/flipper/cli.rb:213:in `colorize': uninitialized constant Flipper::CLI::IRB (NameError)

      IRB::Color.colorize(text, options)
         ^^^^^^^
Did you mean?  ERB
    from /Users/mikemanewitz/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/flipper-1.2.0/lib/flipper/cli.rb:152:in `block in feature_summary'
    from /Users/mikemanewitz/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/flipper-1.2.0/lib/flipper/cli.rb:149:in `map'
    from /Users/mikemanewitz/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/flipper-1.2.0/lib/flipper/cli.rb:149:in `feature_summary'
    from /Users/mikemanewitz/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/flipper-1.2.0/lib/flipper/cli.rb:68:in `block (2 levels) in initialize'
    from /Users/mikemanewitz/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/flipper-1.2.0/lib/flipper/cli.rb:232:in `run'
    from /Users/mikemanewitz/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/flipper-1.2.0/lib/flipper/cli.rb:115:in `run'
    from /Users/mikemanewitz/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/flipper-1.2.0/lib/flipper/cli.rb:6:in `run'
    from /Users/mikemanewitz/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/flipper-1.2.0/exe/flipper:5:in `<top (required)>'
    from /Users/mikemanewitz/.asdf/installs/ruby/3.2.2/bin/flipper:25:in `load'
    from /Users/mikemanewitz/.asdf/installs/ruby/3.2.2/bin/flipper:25:in `<main>'
aitor commented 9 months ago

The same error here on Ruby 2.7.8 and 3.1.4 via rbenv. Manually requiring irb in the cli code in the gem does NOT solve it and moves the error to a point where IRB::Color::WHITE is referenced.

bkeepers commented 9 months ago

Odd, I have Ruby 3.2.2 installed via asdf and can't duplicate. Any other info you can give me about your setup? What rails --version? irb --version?

❯ ruby --version
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]

~/projects/flippercloud flipper-1.2*
❯ flipper list
stats                  is ⏺ enabled
adapter_request_logs   is ⏺ enabled
administrator          is ◯ enabled for 5 actors
docsearch              is ⏺ enabled
expressions            is ⏺ enabled
feature_stats          is ◯ enabled for 7 actors
github_auth            is ⏺ enabled
github_sync            is ⏺ enabled
google_auth            is ⏺ enabled
helpscout              is ⏺ enabled
hubspot                is ⏺ enabled
plausible              is ⏺ enabled
plausible_masked       is ⏺ enabled
rack_mini_profiler     is ◯ enabled for 1 actor
scoped_tokens          is ⏺ enabled
seo                    is ⏺ enabled
subscriptions          is ⏺ enabled
telemetry_receiving    is ⏺ enabled
trail_on_create        is ⏺ enabled
trial_lifecycle_emails is ⏺ enabled
version_check          is ⏺ enabled
webhooks               is ◯ enabled for 1 actor, 5% of actors, 2 groups
neutral_edit_feature   is ⏺ enabled
userlist_onboarding    is ⏺ enabled
new_marketing          is ⦸ disabled
manewitz commented 9 months ago

here's mine:

❯ rails --version
Rails 7.1.2
❯ irb --version
irb 1.11.1 (2024-01-08)
❯ gem --version
3.5.4
manewitz commented 9 months ago

I tried commenting out my .irbrc and removing pry from my Gemfile to see if there was some issues around that but same thing.

bkeepers commented 9 months ago

Ok, I was finally able to duplicate this in a Rails 7.0 app. Rails 7.1 added a dependency on the irb gem, which is where new development is happening to try to get parity with pry.

So we either need to make Flipper depend on irb gem as well, or just make colorization optional if IRB::Color is defined. The latter would probably be my preference.