Bug #17557

IRB array returned in multiple lines

Added by sergioro (Sergio Romero) about 2 months ago. Updated about 2 months ago.

Target version:
ruby -v:
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]


Hi Rubysts. In previous versions of IRB an array was displayed in a single line like:

=> [:unicode_normalize, :unicode_normalize!, :ascii_only?, :to_r, :unpack, ..., :!=, :equal?, :__id__, :instance_eval, :instance_exec]

But in version 1.3.1 (2021-01-12) the array is returned in multiple lines:


Is there a way to toggle this behavior, perhaps IRB.conf?

Updated by k0kubun (Takashi Kokubun) about 2 months ago

  • Status changed from Open to Closed

We changed the default IRB inspector from inspect-based one to pretty_inspect-based one, which prints a content in multiple lines when it exceeds 79 chars, for Ruby 3.1+ IRB.

Given that, we have two choices:

  1. Use IRB.conf[:INSPECT_MODE] = :inspect in your ~/.irbrc. This makes the behavior compatible with Ruby 3.0 IRB, which, however, cannot syntax-highlight an inspect output of objects like Struct.
  2. Dynamically change the threshold 79 using Reline's API in the new pp-based inspector. It would still print an array in a single line as long as it's not too large.

2 would be a valid feature request, but because my comment already addresses the ticket's concern, I'm closing this ticket.

Updated by k0kubun (Takashi Kokubun) about 2 months ago

The point 2 was merged to IRB master It seems 's'.methods returns way more things than what's written in the description and thus it doesn't help your case though.

Updated by sergioro (Sergio Romero) about 2 months ago

Thanks, (1) solved the issue.

Also available in: Atom PDF