Irb login not reading irbrc file

Hi List!

I am beginning to learn Ruby ( vers. 1.8.6) , and I am using OS X
(10.5.4), and accessing irb through terminal. On OS X, irb loads from
a /etc/irbrc file that includes the ‘simple prompt’ code. I don’t
like the simple prompt, and am trying to create my own irbrc for irb
to read when it logs in.

Firstly, the general instructions are to create a ~/.irbrc file, which
I understand as an instruction to create a simple txt file, which I
have called variously “.irbrc”, “$irbrc”, and " “.irbrc” ", and placed
in a ‘ruby’ folder under my home directory (my ‘mac’ house on the
finder)

I then put the code: IRB.conf[:PROMPT_MODE][:DEFAULT] = {:PROMPT_I =>
"%N(%m):%03n:%i>
end

saved it, then exited terminal, restarted it, and logged back into irb.

STILL getting the simple prompt, and the ‘double tab’ auto-completion
thing still works (also a part of the OSX etc irbrc file) so I know
that irb is not reading my irbrc file.

What am I doing wrong? I’ve searched and searched, and I seem to be
following the general instructions pretty well.

cheers and thanks for your time

mac

2009/2/19 Philip McDonald [email protected]:

called variously “.irbrc”, “$irbrc”, and " “.irbrc” ", and placed in a
‘ruby’ folder under my home directory (my ‘mac’ house on the finder)

It must be directly in the home directory.

The ruby folder IS in the ‘home directory’. But I took it out and
moved it directly in the ‘mac’ folder. It still doesn’t work. Maybe
I’m not understanding what a ‘home directory’ is. My understanding is
that a home directory is my main folder for the user, i.e. my ‘mac’
house icon. That’s where the txt file is.

2009/2/19 Philip McDonald [email protected]:

called variously “.irbrc”, “$irbrc”, and " “.irbrc” ", and placed in a
still works (also a part of the OSX etc irbrc file) so I know that irb is
not reading my irbrc file.

What am I doing wrong? I’ve searched and searched, and I seem to be
following the general instructions pretty well.

Try this from a shell prompt (bash assumed):

echo ‘puts “loaded”’ >| ~/.irbrc
irb

If you see “loaded” printed on the screen your rc file is correctly
read. If not, something with your irb or installation may be wrong or
you have an alias like alias irb=‘irb -f’ (try “type -a irb” in bash).

Cheers

robert

On Thu, Feb 19, 2009 at 11:27 AM, Philip McDonald
[email protected]wrote:

The ruby folder IS in the ‘home directory’. But I took it out and moved it
directly in the ‘mac’ folder. It still doesn’t work. Maybe I’m not
understanding what a ‘home directory’ is. My understanding is that a home
directory is my main folder for the user, i.e. my ‘mac’ house icon. That’s
where the txt file is.

I think that you might be confusing the current directory with the home
directory.

The home directory is associated with your userid. In OS X that should
be

/Users/username/

For example on my machine my userid is rick, so

$ ls ~/.irbrc
/Users/rick/.irbrc

HTH

Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

Hey Thanks! That worked! And I quit terminal, restarted, and logged
back into irb and it did it again. So, good stuff, and thanks for
the, uh, “prompt” assistance.

I’m still wondering why it didn’t load up automatically. Is it
supposed to? All the info I read about .irbrc said that when irb is
loading, it looks for those files automatically. What’s up?

mac

On Thu, Feb 19, 2009 at 8:39 AM, Philip McDonald
[email protected] wrote:

Hey Thanks! That worked! And I quit terminal, restarted, and logged back
into irb and it did it again. So, good stuff, and thanks for the, uh,
“prompt” assistance.

For what it’s worth, you don’t need to quit terminal. Just close irb
and start it back up.

I’m still wondering why it didn’t load up automatically. Is it supposed to?
All the info I read about .irbrc said that when irb is loading, it looks
for those files automatically. What’s up?

If what Robert suggested worked, then it is reading your .irbrc when
loading up.

Here’s what you said you put in your ~/.irbrc in your original message:

IRB.conf[:PROMPT_MODE][:DEFAULT] = {:PROMPT_I => "%N(%m):%03n:%i>
end

I can see a couple of problems here. It’s possible that they’re
copy/paste errors, but A) there’s an opening curly brace right after
the first = and no closing curly and B) what’s that end about?

If your ~/.irbrc is invalid, it will fail silently. My guess would be
that it reads /etc/irbrc first, then ~/.irbrc, so if there’s a problem
with your ~/.irbrc, it would seem that it’s not loading.

Hope that helps :slight_smile:

Ben

I’'ll keep that ‘failing silently’ in mind. BTW, it WAS copy/pasted,
and that particular one prompt code was the most complicated one I
saw. I chose it after getting frustrated with a few other ones that
didn’t work. And if I had looked at it a little closer, I should have
caught the missing second curly brace. It works though…

also, OS X is supposed to look for the /etc/irbrc file LAST, after
looking through a few different spellings of /.irbrc. I still don’t
understand what happened, but the problem’s solved, and I’ll continue
the trek.

thanks all for your know-how.

mac

Rick,

I was just reading over this and understood it. Actually, my home
directory IS called ‘mac’. It’s kinda confusing when i use an apple
computer.

thanks though. I hope you got a little chuckle, at least.

mac