When I paste the following text into IRB or PRY running under ruby-enterprise-2011.03, it takes 13 seconds.
# Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Pasting isn't slow when running irb with other ruby installations on the same computer.
jruby-1.5.6
jruby-1.6.3
ruby-1.8.6-p420
ruby-1.8.7-p352
ruby-1.9.1-p431
ruby-1.9.2-p290
ruby-1.9.3-preview1
or Mac OS X's default system install of 1.8.7-p249
This question is related to Rails console running incredibly slowly when editing text, but I'm not using rvm, and there is no slowness when writing, editing, or deleting text; Only pasting is slow. @fl00r's suggestion works, but that isn't a permanent fix.
Also, if there are hard newlines in the pasted text, only the last line is slow. For example, pasting the following text only takes about 1.5 seconds
# Lorem ipsum dolor sit amet, consectetur adipisicing elit,
# sed do eiusmod tempor incididunt ut labore et dolore magna
# aliqua.
I've noticed that REE loads a copy of libreadline that none of the other ruby installations load. Is there a way to configure and compile REE to ignore the libreadline file from MacPorts?
require 'readline'
puts `lsof -p #{$$} | grep -i readline | awk '{print $9}'`
puts
I ran the above script on several ruby installations. Only the bottom 2 installations (the REE installations) include the extra libreadline.
=== ruby-1.8.6-p36 ======================
/opt/ruby-1.8.6-p36/lib/ruby/1.8/i686-darwin11.2.0/readline.bundle
=== ruby-1.8.6-p420 ======================
/opt/ruby-1.8.6-p420/lib/ruby/1.8/i686-darwin11.0.1/readline.bundle
=== ruby-1.8.7-p352 ======================
/opt/ruby-1.8.7-p352/lib/ruby/1.8/i686-darwin11.0.1/readline.bundle
=== ruby-1.9.1-p431 ======================
/opt/ruby-1.9.1-p431/lib/ruby/1.9.1/i386-darwin11.0.1/readline.bundle
=== ruby-1.9.2-p290 ======================
/opt/ruby-1.9.2-p290/lib/ruby/1.9.1/x86_64-darwin11.0.1/readline.bundle
=== ruby-1.9.3-preview1 ==================
/opt/ruby-1.9.3-preview1/lib/ruby/1.9.1/x86_64-darwin11.0.1/readline.bundle
=== ruby-enterprise-1.8.7-2011.03 ========
/opt/ruby-enterprise-1.8.7-2011.03/lib/ruby/1.8/i686-darwin11.0.1/readline.bundle
/opt/local/lib/libreadline.6.2.dylib
=== ruby-enterprise-1.8.7-2012.01 ========
/opt/ruby-enterprise-1.8.7-2012.01/lib/ruby/1.8/i686-darwin11.2.0/readline.bundle
/opt/local/lib/libreadline.6.2.dylib
This is an issue with Readline and UTF-8 terminals. I have not spent the time to track down where the real issue is coming from, however, if you set $LANG to some other value, the problem will disappear.
This isn't a permanent solution.
Another quick fix is to type an additional character after pasting text.
You could alternatively go back to using OSX' editline lib, if you recompiled ruby to not use Readline. Sadly this comes with it's own problems, such as the editline compatibility for rubys readline blocks threads.
I should also note that it's not just ruby that suffers this issue, I have seen it with other readline implementations on OSX since Snow Leopard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With