janlelis/irbtools

`irb -r app.rb` throws an error

Closed this issue · 7 comments

I got a make debug task configured to easily start debugging, it runs irb -r app.rb.
My .irbrc loads irbtools.

require 'irbtools'

When I start a plain IRB session (irb) everything works fine, but when I add the -r app.rb switch this happens:

$ irb -r app.rb
Welcome to IRB. You are using ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-darwin12.2.1]. Have fun ;)
>> 40 + 2
LoadError: Could not load colorizer Paint at /Users/florian/.rvm/gems/ruby-1.9.3-p374/gems/wirb-1.0.1/lib/wirb/colorizer/paint: cannot load such file -- paint
    from /Users/florian/.rvm/gems/ruby-1.9.3-p374/gems/wirb-1.0.1/lib/wirb.rb:41:in `eval'
    from /Users/florian/.rvm/gems/ruby-1.9.3-p374/gems/wirb-1.0.1/lib/wirb/colorizer.rb:14:in `const_missing'
    from (eval):1:in `load_colorizer'
    from /Users/florian/.rvm/gems/ruby-1.9.3-p374/gems/wirb-1.0.1/lib/wirb.rb:41:in `eval'
    from /Users/florian/.rvm/gems/ruby-1.9.3-p374/gems/wirb-1.0.1/lib/wirb.rb:41:in `load_colorizer'
    from /Users/florian/.rvm/gems/ruby-1.9.3-p374/gems/wirb-1.0.1/lib/wirb.rb:82:in `load_schema'
    from /Users/florian/.rvm/gems/ruby-1.9.3-p374/gems/wirb-1.0.1/lib/wirb.rb:47:in `schema'
    from /Users/florian/.rvm/gems/ruby-1.9.3-p374/gems/wirb-1.0.1/lib/wirb.rb:98:in `colorize_result'
    from /Users/florian/.rvm/gems/ruby-1.9.3-p374/gems/irbtools-1.4.0/lib/irbtools/libraries.rb:145:in `view_or_page_output'
    from /Users/florian/.rvm/gems/ruby-1.9.3-p374/gems/hirb-0.7.1/lib/hirb/view.rb:186:in `output_value'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb.rb:160:in `block (2 levels) in eval_input'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb.rb:273:in `signal_status'
    from /Users/florian/.rvm/gems/ruby-1.9.3-p374/gems/fancy_irb-0.7.3/lib/fancy_irb/irb_ext.rb:104:in `signal_status'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb.rb:156:in `block in eval_input'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb/ruby-lex.rb:243:in `block (2 levels) in each_top_level_statement'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `loop'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `block in each_top_level_statement'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `catch'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `each_top_level_statement'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb.rb:155:in `eval_input'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb.rb:70:in `block in start'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb.rb:69:in `catch'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/irb.rb:69:in `start'
    from /Users/florian/.rvm/rubies/ruby-1.9.3-p374/bin/irb:16:in `<main>'Maybe IRB bug!

The weird part is that this actually works fine:

$ irb
Welcome to IRB. You are using ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-darwin12.2.1]. Have fun ;)
>> 40 + 2 #=> 42
>> load 'app.rb'  #=> true
>> 40 + 2 #=> 42

I guess this has something to do with the load path? Inside of app.rb I just prepend my lib folder $LOAD_PATH, but that shouldn't be a problem right?

I installed irbtools with a plain gem install irbtools.

For some reason irb -r app.rb works on my old Ubuntu machine, but not on my new Mac.


The same happens when I directly load in app.rb:

$ irb
Welcome to IRB. You are using ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-darwin12.2.1]. Have fun ;)
>> load 'app.rb'
{{ same backtrace as above }}

Same issue without the -r.
I call irb and then require 'some_file' and I get this exception.

FYI, using the snippet provided in the README, I don't get the error.

require 'irbtools/configure'
Irbtools.remove_library :paint
Irbtools.remove_library :fancy_irb
Irbtools.add_library :paint, :late => true do Wirb.load_schema :classic_paint if defined? Wirb end
Irbtools.add_library :fancy_irb, :thread => -1 do FancyIrb.start end
Irbtools.start

Hi js-coder and simonc,
sorry for my late answer and thank you for opening the bug report and collecting information.

I have no good idea, yet, and cannot reproduce the bug. It's only happening on macbooks so far.

  • Does it also happen with an older version of Ruby?
  • Does it only happen when trying to load a custom file or also when requiring anything?
  • Does irb -r paint work?
  • Does irb -f -r irbtools work?
  • Since when does it happen?

Does it also happen with an older version of Ruby?

I get an error when installing 1.8.7 with rvm right now. Maybe @simonc still has 1.8.7 and can answer this one?

Does it only happen when trying to load a custom file or also when requiring anything?

Just with custom files, requiring something from the standard lib or a gem works fine. Doesn't matter if I use require or load for the custom file.

Does irb -r paint work?
Does irb -f -r irbtools work?

Nope. Tried those earlier, too.

Since when does it happen?

Since I'm on a Mac, so a little over a week now.

Does it still happen? What is the OS version? Is it reproducible with Ruby 2.0?

Closing. Please re-open with more information if this is still a problem for you.