将文本粘贴到IRB中非常慢. Readline问题? [英] Pasting text into IRB is incredibly slow. Readline issue?

查看:85
本文介绍了将文本粘贴到IRB中非常慢. Readline问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将以下文本粘贴到在ruby-enterprise-2011.03下运行的IRB或PRY中时,需要13秒.

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.

在同一台计算机上与其他红宝石安装一起运行irb时,粘贴不会很慢.

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

此问题与编辑文本时,Rails控制台运行得异常缓慢有关,但是我没有使用rvm,并且在编写,编辑或删除文本时也不会出现速度慢的情况;仅粘贴缓慢. @ fl00r的建议有效,但这不是永久解决方法.

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.

此外,如果粘贴的文本中有硬的换行符,则仅最后一行很慢.例如,粘贴以下文本只需大约1.5秒

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. 

我注意到REE加载了libreadline的副本,而其他ruby安装都没有该副本.有没有一种方法可以配置和编译REE以忽略MacPorts中的libreadline文件?

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

我在多个ruby安装上运行了上述脚本.仅底部2个安装(REE安装)包括额外的libreadline.

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

推荐答案

看起来REE的installer.rb添加了-I/opt/local/include-L/opt/local/lib -Wl,链接器标志.清除这些标志后,REE可以成功编译,而无需包含第二个readline库,但是由于其他加载错误,生成的ruby不会执行.

It looks like REE's installer.rb adds -I/opt/local/include and -L/opt/local/lib -Wl, linker flags. After clearing out those flags, REE compiles successfully without including the 2nd readline library, but the resultant ruby will not execute due to other load errors.

一种解决方案是在安装REE时临时删除MacPorts,以使其不链接到额外的readline库.

A solution is to temporarily remove MacPorts while installing REE so that it doesn't link to the extra readline library.

  1. 退出所有正在访问MacPorts文件的进程.您可以看到正在运行sudo lsof | grep /opt/local的计算机.
  2. sudo mv /opt/local /opt/localbak
  3. 打开一个新终端,然后编译并安装REE
  4. sudo mv /opt/localbak /opt/local
  1. Quit all processes that are accessing MacPorts files. You can see which ones are running with sudo lsof | grep /opt/local.
  2. sudo mv /opt/local /opt/localbak
  3. Open a new terminal, then compile and install REE
  4. sudo mv /opt/localbak /opt/local

之后,REE安装将与MacPorts一起正常工作.

After that, the REE installation will work properly alongside MacPorts.

其他解决方案:

  • 永久卸载MacPorts,并照常安装REE
  • 使用MRI或其他版本的Ruby代替REE

编辑:我注意到,使用 ruby​​-build 安装REE a>不会出现此问题

edit: I've noticed that installing REE with ruby-build doesn't exhibit this problem

这篇关于将文本粘贴到IRB中非常慢. Readline问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆