Kevin Dewalt
Kevin Dewalt

Reputation: 777

How do I get IRBRC running on Win32 for Ruby console?

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

Upvotes: 2

Views: 1334

Answers (5)

horseyguy
horseyguy

Reputation: 29895

Use Pry: http://pry.github.com

Lets you:

  • view method source code
  • view method documentation (not using RI so you dont have to pre-generate it)
  • pop in and out of different contexts
  • syntax highlighting
  • gist integration
  • view and replay history
  • open editors to edit method using edit-method obj.my_method syntax

A tonne more great and original features

View the screencast on that link above, it also works with Rails. :)

Upvotes: 1

pdobb
pdobb

Reputation: 18037

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.

Upvotes: 0

John Tobler
John Tobler

Reputation: 414

+1, @rogerdpack for giving me the clue I needed to get IRBRC, Wirble, etc., working on Windows XP Pro. In my case, though, I first had to change to my %HOMEDRIVE%, which was not the "C:" drive, to get the job done. It's all working fine, now, thanks to him! It is not exactly obvious, on XP, how one can create files preceded by a '.'. I wasted considerable time trying to accomplish it with [File | New | Text Document] in Windows Exploder and the Context Menu; they kept telling me "You must type a file name." the post, here, by @rogerdpack led me to use "edit" from the console and it brought up the old DOS editor, blue screen and all, and, after entering some text, using [File | Save} to ".irbrc" let me create the *nix-ed filename. Later, I discovered that my old standby, Notepad++, and some other text editors, will also let you save files with a dot prefix.

I must say that I read a lot of misguiding posts, elsewhere, about various strategies for getting around .irbrc before this question and the post by @rogerdpack put the issue to rest! Thanks! Oh, I might as well mention that Colorized Wirble in windows xp also has a different solution that may help some folks.

Upvotes: 1

rogerdpack
rogerdpack

Reputation: 66741

cd %HOMEPATH%

edit .irbrc

add stuff

Upvotes: 1

rnicholson
rnicholson

Reputation: 4588

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"

Upvotes: 1

Related Questions