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

Updated . Posted . Visible to the public.

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]

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.

Arne Hartherz
Last edit
Dominik Schöler
Keywords
paste
License
Source code in this card is licensed under the MIT License.
Posted by Arne Hartherz to makandra dev (2020-11-27 11:15)