15

次のテキストをruby-enterprise-2011.03で実行されているIRBまたはPRYに貼り付けると、13秒かかります。

# Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

同じコンピューターで他のrubyインストールを使用してirbを実行している場合、貼り付けは遅くありません。

  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の提案は機能しますが、それは恒久的な修正ではありません。

また、貼り付けたテキストに改行が含まれている場合は、最後の行だけが遅くなります。たとえば、次のテキストの貼り付けには約1.5秒しかかかりません

# Lorem ipsum dolor sit amet, consectetur adipisicing elit, 
# sed do eiusmod tempor incididunt ut labore et dolore magna 
# aliqua. 

REEがlibreadlineのコピーをロードし、他のどのrubyインストールもロードしないことに気づきました。MacPortsからのlibreadlineファイルを無視するようにREEを設定およびコンパイルする方法はありますか?

require 'readline'
puts `lsof -p #{$$} | grep -i readline | awk '{print $9}'`
puts

上記のスクリプトをいくつかのrubyインストールで実行しました。下位2つのインストール(REEインストール)のみに追加の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
4

4 に答える 4

4

これは、Readline および UTF-8 端末の問題です。私は、実際の問題がどこから来ているのかを追跡するのに時間を費やしていませんが、$LANG を別の値に設定すると、問題は解消されます。

これは恒久的な解決策ではありません。

もう 1 つの簡単な修正方法は、テキストを貼り付けた後に追加の文字を入力することです。

readline を使用しないように ruby​​ を再コンパイルした場合は、代わりに OSX の editline lib を使用するように戻すこともできます。悲しいことに、これには、ruby の readline ブロック スレッドに対する editline の互換性など、独自の問題があります。

また、この問題が発生するのは ruby​​ だけではないことにも注意してください。Snow Leopard 以降、OSX の他の readline 実装で見てきました。

于 2011-09-28T18:29:50.447 に答える
0

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.

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

  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

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

Other solutions:

  • Uninstall MacPorts permanently, and install REE as usual
  • Use MRI or another version of Ruby instead of REE

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

于 2012-03-20T19:27:54.750 に答える
0

多分純粋なルビーのreadlineをインストールしますか?

于 2012-02-10T20:09:22.217 に答える
0

追加してみてください:

IRB.conf[:USE_MULTILINE] = false

~/.irbrcファイルに移動し、irb を再起動 (または実行中load '~/.irbrc')

于 2021-04-20T13:17:41.160 に答える