awesome-print / awesome_print

Pretty print your Ruby objects with style -- in full color and with proper indentation
http://github.com/michaeldv/awesome_print
MIT License
4.07k stars 454 forks source link

irb: ArgumentError (wrong number of arguments (given 1, expected 0)) #389

Closed febeling closed 3 years ago

febeling commented 3 years ago

Some expressions in irb result in an ArgumentError.

Consider this example:

$ irb
irb(main):001:0> x, y = "12in".scan(/^(\d+)(in|cm)$/)
Traceback (most recent call last):
        4: from /Users/febeling/.rbenv/versions/2.7.2/bin/irb:23:in `<main>'
        3: from /Users/febeling/.rbenv/versions/2.7.2/bin/irb:23:in `load'
        2: from /Users/febeling/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/irb-1.2.7/exe/irb:11:in `<top (required)>'
        1: from /Users/febeling/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/awesome_print-2.0.0.pre2/lib/awesome_print/custom_defaults.rb:22:in `output_value'
ArgumentError (wrong number of arguments (given 1, expected 0))

This is a distinct problem from #330, because it's in the context of using irb.

This commit https://github.com/ruby/irb/commit/c5ea79d5cecea9cae6ad0c1f31703a98cd329431 in IRB changed the signature of IRB::Irb#output_value to add one default argument.

When overriding same method in awesome_print https://github.com/awesome-print/awesome_print/blob/master/lib/awesome_print/custom_defaults.rb#L30 without this default parameter, the error is raised.

febeling commented 3 years ago

This is fixed in the fork AmazingPrint: https://github.com/amazing-print/amazing_print/pull/57/files

Maybe it's time to switch to this maintained alternative. The fix is exactly the same.

BryanH commented 3 years ago

PR will be merged once checks complete