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

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)

It must be directly in the home directory.

···

2009/2/19 Philip McDonald <philip_mcdonald@mac.com>:

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

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

···

2009/2/19 Philip McDonald <philip_mcdonald@mac.com>:

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.

--
remember.guy do |as, often| as.you_can - without end

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.

···

On Feb 19, 2009, at 11:12 AM, Stefan Lang wrote:

2009/2/19 Philip McDonald <philip_mcdonald@mac.com>:

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)

It must be directly in the home directory.

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

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 Feb 19, 2009, at 11:31 AM, Robert Klemme wrote:

2009/2/19 Philip McDonald <philip_mcdonald@mac.com>:

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.

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

--
remember.guy do |as, often| as.you_can - without end

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

···

On Thu, Feb 19, 2009 at 11:27 AM, Philip McDonald <philip_mcdonald@mac.com>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.

--
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.

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

···

On Thu, Feb 19, 2009 at 8:39 AM, Philip McDonald <philip_mcdonald@mac.com> wrote:

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

···

On Feb 19, 2009, at 12:32 PM, Ben Bleything wrote:

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

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

···

On Feb 19, 2009, at 11:42 AM, Rick DeNatale wrote:

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