views:

244

answers:

3

Can anyone suggest some troubleshooting approaches for getting IRBRC running under Win32? The rails console is an awesome tool and I'm attempting to extend it with more functionality.

For instance, I would like the what_method gem to load automatically. The gem is installed but it does not load:

C:\...\trunk>ruby script\console
Loading development environment (Rails 2.3.2)
>> 3.45.what? 3
NoMethodError: undefined method `what?' for 3.45:Float
        from (irb):1
>> require 'what_methods'
=> ["DummyOut", "WhatMethods"]
>> 3.34.what? 3
3.34.round_with_precision == 3
...
=> ["round_with_precision", "round", "prec_i", ... "round_without_precision"]
>>

My environment is setup as

C:\...\trunk>dir %HOME%
 Volume in drive C is OS
...
06/21/2009  10:29 AM    <DIR>          .
06/21/2009  09:28 AM               118 .irbrc
...

Environment variable path IRBRC = %HOME%\.irbrc

.irbrc file

require 'irb/completion'
require 'map_by_method'
require 'what_methods'
require 'pp'
IRB.conf[:AUTO_INDENT]=true

I've read the following references

http://railscasts.com/episodes/48-console-tricks

http://drnicwilliams.com/2006/10/12/my-irbrc-for-consoleirb/#irbrc_win32

http://groups.google.com/group/ruby-talk-google/browse_thread/thread/23fe3980a5a4816e

http://www.nabble.com/.irbrc-on-Windows-td23954309.html

+1  A: 

If you're looking to have the 'what_methods' gem autoloaded in a Rails environment, you could just specify it via config.gem in your Rails config inside of RAILS_ROOT\config\environment.rb:

Rails::Initializer.run do |config|
...
  config.gem "what_methods"
...
end

or for development only, just add it in your RAILS_ROOT\config\environments\development.rb:

config.gem "what_methods"
rnicholson
thanks rnicholson. I guess that will help get the gems in the console but it won't help other console settings. But thanks for this advice, it will help.
Kevin Dewalt
A: 

cd %HOMEPATH%

edit .irbrc

add stuff

rogerdpack
I don't understand. edit differently than I stated in the original question?
Kevin Dewalt
Hmm. Yeah it *should* be loading that file and doing it all right. A few hints might be: add some puts in that file, make sure your directory matches File.expand_path('~') [since that's where ruby will load it from], and that it's readable from within a ruby process [should be].GL.=r
rogerdpack
A: 

Try setting your Environment Variable path for IRBRC to use "_irbrc" instead of ".irbrc" - yes even though the file in your home path is still actually called ".irbrc". For example, my IRBRC variable is "%HOMEPATH%_irbrc" and the file it is referring to is "C:\Users\Paul.irbrc".