From: Kaye Ng on
To James, I'm still on windows xp.

I tried putting the calc.rb file inside the bin folder, and "ruby
calc.rb" worked, as well as "calc" and "calc.rb"

Is this what you guys were saying?

The tutorial didn't say anything about the bin folder or where exactly
to save the programs. It only said to make a folder wherein my programs
could be saved, and that's what I did. But then it instructed to type
"ruby calc.rb" and I got confused.

I still don't understand the logic behind it.
Do I have to bother with this?
Do I always have to save my programs in the bin folder?

Please excuse the ignorance. I'm a novice.

--
Posted via http://www.ruby-forum.com/.

From: Jesús Gabriel y Galán on
On Tue, Jul 27, 2010 at 8:43 AM, Kaye Ng <sbstn26(a)yahoo.com> wrote:
> To James, I'm still on windows xp.
>
> I tried putting the calc.rb file inside the bin folder, and "ruby
> calc.rb" worked, as well as "calc" and "calc.rb"
>
> Is this what you guys were saying?
>
> The tutorial didn't say anything about the bin folder or where exactly
> to save the programs.  It only said to make a folder wherein my programs
> could be saved, and that's what I did.  But then it instructed to type
> "ruby calc.rb" and I got confused.
>
> I still don't understand the logic behind it.
> Do I have to bother with this?
> Do I always have to save my programs in the bin folder?
>
> Please excuse the ignorance. I'm a novice.

No problem, we were all novices at some point in time. When you type
"ruby" in the cmd window, Windows has to know to which program you
refer to. For this, it uses the environment variable PATH, which
contains a list of folders to search for executables. When you are in
any folder in your system and type the name of a program, it searches
in the current folder and then in all folders in that variable until
it finds a suitable named program to run. If it doesn't find one, it
spits the message "ruby is not recognized, etc, etc". A way to solve
it so that you can call ruby from wherever folder, is to add the path
to the ruby executable to your PATH environment variable. Others have
explained how to do that in Windows (there are some menus to click and
so on).

With this, then you can place your rb files wherever you want, and
call the ruby executable from that folder.

Hope this helps,

Jesus.

From: Jarmo Pertman on
If you don't know how to change PATH variable in Windows (then you
should learn it of course), then you can install Ruby again from
http://rubyinstaller.org/ but this time check also the checkbox, which
says something about "add to PATH". For some reason this is not
checked by default.

And please don't put your Ruby scripts into Ruby\bin directory - it
will be a mess after a while.

-----
Jarmo Pertman
IT does really matter - http://www.itreallymatters.net
From: Swifty on
On Tue, 27 Jul 2010 10:28:56 -0700 (PDT), Jarmo Pertman
<jarmo.p(a)gmail.com> wrote:

>And please don't put your Ruby scripts into Ruby\bin directory - it
>will be a mess after a while.

It used to be the habit of my employers to send us our PC's with a
C:\$user directory already defined. Anything you put in here would be
copied to your next PC by the migration process. I copy C:\$user to my
memory stick as a precaution.

So I create a C:\$user\tools directory for all of the little programs
that I write, and the simpler ones that I download. So adding
C:\$user\tools to the PATH variable, and adding ;.RB to the PATHEXT
variable allows me to run C:\$user\tools\neat.rb with the command
"neat" whichever directory I'm in.

You have to learn to avoid conflicts with other programs that may take
precedence; executing just "test" is asking for trouble as it may well
not run your C:\$user\tools\test.rb

--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk