# Default IRB Directory

**URL:** <https://rubytalk.org/t/default-irb-directory/38302>\
**Category:** ruby-talk\
**Created:** [13 June 2007 05:04 UTC](https://rubytalk.org/t/default-irb-directory/38302 "2007-06-13T05:04:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rpg\_Action](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@Rpg\_Action](https://rubytalk.org/u/Rpg_Action)\
**Post date:** [13 June 2007 05:04 UTC](https://rubytalk.org/t/default-irb-directory/38302/1 "2007-06-13T05:04:03Z")

</div>

I'm new to Ruby, and I've never used a similar language that could be  
executed from the command line, so I'm pretty clueless in these first  
couple of steps, and I hope that you'll help me here.

Is there a way under Windows that I can set the default IRB directory to  
a specific folder? Right now the default is C:\, and I've no idea how to  
go about changing it.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Nilesh\_Kumar](https://avatars.discourse-cdn.com/v4/letter/n/779978/32.png) [@Nilesh\_Kumar](https://rubytalk.org/u/Nilesh_Kumar)\
**Post date:** [13 June 2007 15:16 UTC](https://rubytalk.org/t/default-irb-directory/38302/2 "2007-06-13T15:16:09Z")

</div>

In commnad prompt type irb  
and here you are on IRB directory and for coming out of this type exit.  
Thanks.

> **···**
>
> On 6/13/07, Rpg Action \<rpgaction@gmail.com\> wrote:
> 
> > I'm new to Ruby, and I've never used a similar language that could be  
> > executed from the command line, so I'm pretty clueless in these first  
> > couple of steps, and I hope that you'll help me here.
> > 
> > Is there a way under Windows that I can set the default IRB directory to  
> > a specific folder? Right now the default is C:\, and I've no idea how to  
> > go about changing it.
> > 
> > --  
> > Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![vasudevram](https://avatars.discourse-cdn.com/v4/letter/v/bbce88/32.png) [@vasudevram](https://rubytalk.org/u/vasudevram)\
**Post date:** [13 June 2007 19:25 UTC](https://rubytalk.org/t/default-irb-directory/38302/3 "2007-06-13T19:25:02Z")

</div>

Create a shortcut on the Windows Desktop for IRB using Windows  
Explorer.  
Then right-click on the shortcut and in the dialog that pops up, look  
for the field labeled "Start in" (not sure of the exact label for the  
field, not at my PC now, but in the dialog the label/field should be  
evident/self-explanatory). In that field, enter the name of the folder  
that you want IRB to start in.

But sorry, this won't help you if you want to run IRB from the command  
line - from a DOS command prompy, that is. You'll have to double-click  
on the shortcut on the Desktop for this technique to work.

One way to make this work from the command line is to create a batch  
file called, say, irb0.bat (or any suitable name), and in that file,  
put these lines:

@echo off  
cd your\_folder\_name here  
irb

Then put that file irb0.bat in some folder which is in your PATH, and  
run it from any folder when you are in a DOS window. It should do what  
you want.

Or, if you want to come back to the directory from which you run the  
irb0 file (after the batch file terminates - since the version shown  
above will leave you in the your\_folder\_name folder), change the "cd"  
in the 2nd line of the batch file to "pushd" and add a line "popd"  
below the line "irb".

Not tested as I'm not at my PC but looks correct to me.

P.S. If you want to pass arguments to irb, change the "irb" line to:

irb %1 %2 %3 (and so on upto %9)

Then you can pass upto 9 command-line arguments to irb0 when you call  
it, and those will be passed on to irb.

Vasudev Ram

> **[dancingbison.com](http://ww38.dancingbison.com/)**
>
> Learn Python Programming

> **···**
>
> On Jun 13, 10:04 am, Rpg Action \<rpgact...@gmail.com\> wrote:
> 
> > I'm new to Ruby, and I've never used a similar language that could be  
> > executed from the command line, so I'm pretty clueless in these first  
> > couple of steps, and I hope that you'll help me here.
> > 
> > Is there a way under Windows that I can set the default IRB directory to  
> > a specific folder? Right now the default is C:\, and I've no idea how to  
> > go about changing it.
> > 
> > --  
> > Posted viahttp://www.ruby-forum.com/.

---

<div class="post-metadata">

**Author:** ![Dejan\_Dimic](https://avatars.discourse-cdn.com/v4/letter/d/e19adc/32.png) [@Dejan\_Dimic](https://rubytalk.org/u/Dejan_Dimic)\
**Post date:** [13 June 2007 20:30 UTC](https://rubytalk.org/t/default-irb-directory/38302/4 "2007-06-13T20:30:14Z")

</div>

Can you be more specific what you try to achieve?  
Irb is an interpreter console.  
If you start it from the command prompt then the current directory  
will be the working directory. It you start if from the some kind  
shortcut then you can define the "Start in" or working directory.  
But the key question still remains: what do you want to achieve?

> **···**
>
> On Jun 13, 7:04 am, Rpg Action \<rpgact...@gmail.com\> wrote:
> 
> > I'm new to Ruby, and I've never used a similar language that could be  
> > executed from the command line, so I'm pretty clueless in these first  
> > couple of steps, and I hope that you'll help me here.
> > 
> > Is there a way under Windows that I can set the default IRB directory to  
> > a specific folder? Right now the default is C:\, and I've no idea how to  
> > go about changing it.
> > 
> > --  
> > Posted viahttp://www.ruby-forum.com/.

---

<div class="post-metadata">

**Author:** ![vasudevram](https://avatars.discourse-cdn.com/v4/letter/v/bbce88/32.png) [@vasudevram](https://rubytalk.org/u/vasudevram)\
**Post date:** [13 June 2007 19:35 UTC](https://rubytalk.org/t/default-irb-directory/38302/5 "2007-06-13T19:35:04Z")

</div>

P.S. I wrote too soon. It looks to me like there's a much simpler way  
to do it. From your description it looks like you're not familiar with  
the DOS prompt. The default folder for IRB is not C:\ - it is whatever  
folder you run the irb command from. So you just have to do a "cd" to  
the folder you want to work in, then run the irb (no need for the  
irb0.bat) command there.

E.g.:

cd /d c:\my\folder\name\wherever\it\is  
irb

(The /d changes the drive as well, to C:, in case you were at a  
different drive when you gave the command.)  
It would be a good idea to learn more about the DOS prompt and DOS  
commands - Google for "DOS tutorial", "DOS commands", and variations  
of the same.

Also type "help" at a DOS prompt. Do it like this:

C:\\> help \> dos\_help.txt  
Then open the file dos\_help.txt in a text editor and read it.

For most DOS commands, you can use "help command", e.g. "help dir", or  
"dir /?" to get some help on them.

If you want to work with irb, or the ruby command from the command-  
line (DOS prompt), its pretty much necessary to have some basic DOS  
knowledge. Not everything can be done from GUI's alone ...

Vasudev Ram

> **[dancingbison.com](http://ww38.dancingbison.com/)**
>
> Learn Python Programming

> **···**
>
> On Jun 14, 12:22 am, vasudevram \<vasudev...@gmail.com\> wrote:
> 
> > On Jun 13, 10:04 am, Rpg Action \<rpgact...@gmail.com\> wrote:
> > 
> > \> I'm new to Ruby, and I've never used a similar language that could be  
> > \> executed from the command line, so I'm pretty clueless in these first  
> > \> couple of steps, and I hope that you'll help me here.
> > 
> > \> Is there a way under Windows that I can set the default IRB directory to  
> > \> a specific folder? Right now the default is C:\, and I've no idea how to  
> > \> go about changing it.
> > 
> > \> --  
> > \> Posted viahttp://www.ruby-forum.com/.
> > 
> > Create a shortcut on the Windows Desktop for IRB using Windows  
> > Explorer.  
> > Then right-click on the shortcut and in the dialog that pops up, look  
> > for the field labeled "Start in" (not sure of the exact label for the  
> > field, not at my PC now, but in the dialog the label/field should be  
> > evident/self-explanatory). In that field, enter the name of the folder  
> > that you want IRB to start in.
> > 
> > But sorry, this won't help you if you want to run IRB from the command  
> > line - from a DOS command prompy, that is. You'll have to double-click  
> > on the shortcut on the Desktop for this technique to work.
> > 
> > One way to make this work from the command line is to create a batch  
> > file called, say, irb0.bat (or any suitable name), and in that file,  
> > put these lines:
> > 
> > @echo off  
> > cd your\_folder\_name here  
> > irb
> > 
> > Then put that file irb0.bat in some folder which is in your PATH, and  
> > run it from any folder when you are in a DOS window. It should do what  
> > you want.
> > 
> > Or, if you want to come back to the directory from which you run the  
> > irb0 file (after the batch file terminates - since the version shown  
> > above will leave you in the your\_folder\_name folder), change the "cd"  
> > in the 2nd line of the batch file to "pushd" and add a line "popd"  
> > below the line "irb".
> > 
> > Not tested as I'm not at my PC but looks correct to me.
> > 
> > P.S. If you want to pass arguments to irb, change the "irb" line to:
> > 
> > irb %1 %2 %3 (and so on upto %9)
> > 
> > Then you can pass upto 9 command-line arguments to irb0 when you call  
> > it, and those will be passed on to irb.
> > 
> > Vasudev Ram  
> > [http://www.dancingbison.com](http://www.dancingbison.com)

---

<div class="post-metadata">

**Author:** ![Nobuyoshi\_Nakada1](https://avatars.discourse-cdn.com/v4/letter/n/9f8e36/32.png) [@Nobuyoshi\_Nakada1](https://rubytalk.org/u/Nobuyoshi_Nakada1)\
**Post date:** [14 June 2007 03:10 UTC](https://rubytalk.org/t/default-irb-directory/38302/6 "2007-06-14T03:10:57Z")

</div>

Hi,

At Thu, 14 Jun 2007 04:25:02 +0900,  
vasudevram wrote in [ruby-talk:255512]:

> But sorry, this won't help you if you want to run IRB from the command  
> line - from a DOS command prompy, that is. You'll have to double-click  
> on the shortcut on the Desktop for this technique to work.

&nbsp;&nbsp;ruby -C "somewhere you want" -S irb

or

&nbsp;&nbsp;ruby -C "somewhere you want" -rirb -e IRB.start

> **···**
>
> --  
> Nobu Nakada

---

<div class="post-metadata">

**Author:** ![vasudevram](https://avatars.discourse-cdn.com/v4/letter/v/bbce88/32.png) [@vasudevram](https://rubytalk.org/u/vasudevram)\
**Post date:** [26 June 2007 12:10 UTC](https://rubytalk.org/t/default-irb-directory/38302/7 "2007-06-26T12:10:05Z")

</div>

Cool, didn't know that, thanks. Good thing I came back to look at this  
post ... :). Guess that implies that you can pass any Ruby command-  
line option to irb using this method of invoking it.

Vasudev

> **···**
>
> On Jun 14, 8:10 am, Nobuyoshi Nakada \<n...@ruby-lang.org\> wrote:
> 
> > Hi,
> > 
> > At Thu, 14 Jun 2007 04:25:02 +0900,  
> > vasudevram wrote in [ruby-talk:255512]:
> > 
> > \> But sorry, this won't help you if you want to run IRB from the command  
> > \> line - from a DOS command prompy, that is. You'll have to double-click  
> > \> on the shortcut on the Desktop for this technique to work.
> > 
> > &nbsp;&nbsp;ruby -C "somewhere you want" -S irb
> > 
> > or
> > 
> > &nbsp;&nbsp;ruby -C "somewhere you want" -rirb -e IRB.start
> > 
> > --  
> > Nobu Nakada
