From: Jesús Gabriel y Galán on
On Mon, Jul 26, 2010 at 12:29 PM, Kaye Ng <sbstn26(a)yahoo.com> wrote:
> Beginner here (in ANY programming language), so pls bear with me.
>
> Please see the first example on this page.
> http://pine.fm/LearnToProgram/?Chapter=01
>
> It says to type in ruby calc.rb
>
> I find it doesn't work.
> What works are:
> calc.rb
> or simply
> calc
>
> Am I wrong? I saved the calc.rb in G:\Ruby\Practice
> I opened command prompt in Accessories, went to G:\Ruby\Practice ,
> then typed ruby calc.rb
>
> G:\Ruby\Practice>ruby calc.rb
> 'ruby' is not recognized as an internal or external command,
> operable program or batch file.

I'm not a Windows expert, but what this is saying is that "ruby", the
ruby executable, is not in your PATH.
You could put it in your path, IIRC, in some global settings (search
for setting environment variables in Windows)

> so I typed calc.rb and it worked.

This is probably because you (or the Ruby installation program) have
associated .rb programs to the ruby executable (you can check this in
the File Types Association in some contextual menu in the Explorer, I
think).

> calc also worked.

I'm totally guessing here, but it might be that the Windows cmd
expands a command with existing files in the current directory, if it
doesn't find a command like that?

Jesus.

From: Guillaume Bloss on
I agree with Jesús Gabriel y Galán :

the ruby command will only work if you put the "$path\ruby\bin" in your
PATH
-> right click on computer, then properties, advanced, environment
variables, edit your PATH variable and add you ruby path ex :
c:\ruby\bin;.....
dont delete or modify existing path ^^

it's may be usefull if you want see ruby errors


If you only type the filename like calc.rb, windows will try to run the
file with the assiociated program in your case, ruby, so it will work
fine, but if you will get an error, the cmd window will be close with
your ruby application.

If you only run calc, without the ".rb" windows will try ton run
runnable file with calc name ... That could be a problem if for example
you use ocra to get a ruby exe (named calc.exe) and you still have your
calc.rb in the same folder.

I dont know how windows will react ... it may ask you if you want run
the .exe or the .rb, or send you an error, or maybe run the .exe ..
--
Posted via http://www.ruby-forum.com/.

From: James on
[Note: parts of this message were removed to make it a legal post.]

As a curiosity issue, what version of Windows are you using? Because Windows
7, at least, has a different way you can edit the user specific PATH
variable rather than the system PATH variable.
Control Panel -> User accounts -> Change my environment variables