Read more

How to fix: Pasting in IRB 1.2+ is very slow

Arne Hartherz
November 27, 2020Software engineer at makandra GmbH

IRB 1.2 (shipped with Ruby 2.7, but works on 2.5+) brings pretty syntax highlighting and multiline cursor navigation. However, pasting longer contents is incredibly slow. You can fix that by disabling said features. [1]

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

Ruby 3.0.0-pre2 solved the issue Show archive.org snapshot (however, the fix does not appear to be included in IRB 1.2.6, it must be Ruby itself).

Option 1:

Add a command line flag when opening an IRB:

irb --nomultiline

This also works on modern Rails when using rails console like so:

rails console -- --nomultiline

Option 2: Disable by default

In your ~/.irbrc, add:

IRB.conf[:USE_MULTILINE] = false

Your IRB will be less pretty, but pasting will be fast again.


[1] Background:

It seems that multiline mode is the culprit, disabling colorization itself neither fixes nor improves the issue. However, disabling multiline mode implies disabling colorization.

Inspection output will still be colorized, unless you use --nocolorize or IRB.conf[:USE_COLORIZE] = false.

Posted by Arne Hartherz to makandra dev (2020-11-27 12:15)