Ari Russo
Ari Russo

Reputation: 273

Trouble with threads in OSX and Ruby 1.9.2

Running the following code in IRB:

t = Thread.new { loop { puts 'Hi' } }

I receive a single hi and then no more output. Only if I begin pressing the enter key do I receive output as expected until I discontinue pressing enter.

If I do t.join, everything acts as expected

The problem happens in IRB, pry and ripl using ruby 1.9.2-p180 and 1.9.2-p290 under rvm 1.8.0 in OSX 10.7 and rvm 1.6.20 in OSX 10.6

readline is installed via rvm pkg install readline

Thank you for any insight

Upvotes: 1

Views: 366

Answers (1)

Ari Russo
Ari Russo

Reputation: 273

Some versions of readline on OSX are blocking. If you experience the behavior above, you can disable readline by putting

IRB.conf[:USE_READLINE] = false

in .irbrc

Upvotes: 2

Related Questions