pete / live-console

LiveConsole, a Ruby gem for providing IRB over things other than stdio.
http://debu.gs/live-console
29 stars 4 forks source link

1.9.2: undefined method `external_encoding' for nil:NilClass #4

Open rkumar opened 13 years ago

rkumar commented 13 years ago

Using 1.9.2: when i connect netcat, i keep getting an exception:

undefined method external_encoding' for nil:NilClass /Users/rahul/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb/input-method.rb:70:inencoding' /Users/rahul/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb/ruby-lex.rb:242:in block (2 levels) in each_top_level_statement' /Users/rahul/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb/ruby-lex.rb:229:inloop' /Users/rahul/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in block in each_top_level_statement' /Users/rahul/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb/ruby-lex.rb:228:incatch' /Users/rahul/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in each_top_level_statement' /Users/rahul/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb.rb:155:ineval_input' /Users/rahul/.rvm/gems/ruby-1.9.2-head/gems/live_console-0.2.1/lib/live_console.rb:150:in block in start_with_io' /Users/rahul/.rvm/gems/ruby-1.9.2-head/gems/live_console-0.2.1/lib/live_console.rb:148:incatch' /Users/rahul/.rvm/gems/ruby-1.9.2-head/gems/live_console-0.2.1/lib/live_console.rb:148:in start_with_io' /Users/rahul/.rvm/gems/ruby-1.9.2-head/gems/live_console-0.2.1/lib/live_console.rb:70:inblock (2 levels) in start' /Users/rahul/.rvm/gems/ruby-1.9.2-head/gems/live_console-0.2.1/lib/live_console.rb:65:in loop' /Users/rahul/.rvm/gems/ruby-1.9.2-head/gems/live_console-0.2.1/lib/live_console.rb:65:inblock in start'

However, when i run in 1.8.7, it works. Could someone look into how to fix this for 1.9.x (I am on OSX Snow Leopard) Thanks, rkumar

rkumar commented 13 years ago

I commented out a line in irb to get the sample to work. I hope someone can fix live_console so irb does not need to be modified. thanks.

rkumar commented 13 years ago

For anyone else who faces the above problem when using 1.9.x, you can do the following in IRB:

ruby-lex.rb 242: @line.force_encoding(@io.encoding) 242: @line.force_encoding(@io.encoding) rescue "" # ADDED RESCUE

Now it works. Thanks for the great utility.