Newbie - cmd question

I’ve literally JUST downloaded ruby from rubyinstaller.org.
Unfortunately I’m running windows 7 (too poor for mac).

My tutorial book says to type “ruby -v” into the cmd prompt to output
the version of ruby I’m running (v 1.9.3).

If I do this at the Command Prompt, it says “ruby is not
recognized as an internal or external command, operable program or batch
file”

But if I go into the ruby program file and open “Start Command Prompt
With Ruby” and type “ruby -v” then it outputs the correct version data.

Why is this?

Sorry I’m such a beginner.

OK thank you, I uninstalled & reinstalled, checking the three boxes at
installation so now .rb files show up as ruby and not text files, etc.

so now i go to command and type “puts 1+2” and it’s supposed to return
“3” but it says instead:

‘puts’ is not recognized as an internal or external command, operable
program or batch file.

What am I doing wrong? my tutorial book doesn’t say this is a common
problem. Does this have anything to do with running win 7 64bit?

Otto D. wrote in post #1032638:

I’ve literally JUST downloaded ruby from rubyinstaller.org.
Unfortunately I’m running windows 7 (too poor for mac).

My tutorial book says to type “ruby -v” into the cmd prompt to output
the version of ruby I’m running (v 1.9.3).

If I do this at the Command Prompt, it says “ruby is not
recognized as an internal or external command, operable program or batch
file”

But if I go into the ruby program file and open “Start Command Prompt
With Ruby” and type “ruby -v” then it outputs the correct version data.

Why is this?

For “ruby” command be available in any command prompt, the Ruby
installation you did needs to be available in the PATH.

By default, RubyInstaller do not modify the user’s environment.

You can change that during installation, please see the checkboxes shown
during the installer execution.


Luis L.

did you type “irb” first to bring up the ruby command prompt?

it should look something like this:

ruby-1.8.7-p334 :001 >

–ian

‘puts’ is not recognized as an internal or external command, operable
program or batch file.

What am I doing wrong? my tutorial book doesn’t say this is a common
problem. Does this have anything to do with running win 7 64bit?

– dont sweat buddy the problem is u typed in puts in a string its suppose to be
like this
puts “1+2”

Thank you all so much. Ian, you are right - typing “irb” first brought
up the prompt as you described and then “puts 1+2” returned “3” !!!

I’ll send a note to the publisher of this “Learn to Program” book. They
should totally have that in there.

Wow I shouldn’t be this happy about programming on a friday night but
you guys are AWESOME. Thank you so much.

On Fri, Nov 18, 2011 at 22:58, Otto D. [email protected] wrote:

Wow I shouldn’t be this happy about programming on a friday night but
you guys are AWESOME. Thank you so much.

IMHO, that’s actually one of the best things about Ruby – the
community. I don’t think I’ve seen such warm welcoming and
willingness to help, in the community of any other language. (And
this from the guy who, at the other extreme, owns the LinkedIn Plain
Old C programming group!)

-Dave

Otto D. wrote in post #1032658:

I’ll send a note to the publisher of this “Learn to Program” book. They
should totally have that in there.

RubyInstaller creates two shortcuts inside the Start menu:

“Interactive Ruby” (also known as IRB)

And “Start Command Prompt with Ruby”

The first one is where the book should be referring to.

The second one is a command line (cmd.exe) where Ruby-related commands
can be executed, like “gem install” and others in case you didn’t add
Ruby to your PATH.

Mention that to the publishers of the Book.

Cheers,

Luis L.

Hussain A. wrote in post #1036281:

Hi all,

I have a similar problem, but the solutions discussed here don’t seem to
be working for me. Actually I have two problems, but am sure they are
related to the same issue.

If I start the command prompt by clicking on “start command prompt with
Ruby”, then Ruby commands are available; i.e., I can type “ruby
helloworld.rb” (where helloworld.rb is a file I have created) and it
will execute the code. However, if I go to the command prompt using
start menu and typing “cmd”, it does not respond to “irb”, “ruby -v”,
“ruby helloworld.rb”, etc.

There is an option in the installer to make Ruby and other Ruby provided
executables available in your PATH.

It is called “Add Ruby executables to your PATH”.

And by default is unchecked to avoid it interfere with other Ruby
installations in your system.

You can start the installer again, select that option and will require
closing and starting both the command prompts and the editors so they
get the PATH changes.


Luis L.

Hi all,

I have a similar problem, but the solutions discussed here don’t seem to
be working for me. Actually I have two problems, but am sure they are
related to the same issue.

If I start the command prompt by clicking on “start command prompt with
Ruby”, then Ruby commands are available; i.e., I can type “ruby
helloworld.rb” (where helloworld.rb is a file I have created) and it
will execute the code. However, if I go to the command prompt using
start menu and typing “cmd”, it does not respond to “irb”, “ruby -v”,
“ruby helloworld.rb”, etc.

The attached screenshot shows the problem, with top left showing the cmd
prompt with Ruby, and the bottom left showing the normal cmd prompt
(giving the error “ruby is not recognized as an internal or external
command, operable program or batch file”). I reinstalled twice, making
sure I check the 3 check boxes during installation, but still have the
same problem.

Additionally, if I use SciTE to try to run a program called
“helloworld.rb”, it gives me the error “the system cannot find the file
specified”. Again, shown on the screenshot, right side.

Any suggestions? Much appreciate the help.

There is an option in the installer to make Ruby and other Ruby provided
executables available in your PATH.

It is called “Add Ruby executables to your PATH”.

And by default is unchecked to avoid it interfere with other Ruby
installations in your system.

You can start the installer again, select that option and will require
closing and starting both the command prompts and the editors so they
get the PATH changes.


Luis L.

Thanks Luis for the response.

I have reinstalled a couple of times now, making sure the option was
checked at the time of installation. Restarting after each uninstall and
reinstall. Still doesn’t work.

Is it possible that the problem has to do with the permissions I have on
my machine (I am using my work machine, on which I have limited rights).
It is letting me install Ruby without raising errors though.

Thanks.

Are you talking about a fresh command prompt after you installed?

Yes.

What is the value of PATH?

When I “start command prompt wit ruby”, Path value is:

PATH=C:\Ruby193\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Program
Files\Intel\WiFi\bin;C:\Program Files\Common Files\Ulead Systems\MPEG

When I go to a normal command prompt, the Path value is:

PATH=C:\Ruby193\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Program
Files\Intel\WiFi\bin;C:\Program Files\Common Files\Ulead Systems\MPEG

So while I can see the difference, I can’t seem to fix it.

I recommend you join RubyInstaller list:

http://groups.google.com/group/rubyinstaller/

Thanks… will do.

Much appreciate the help.

Hussain A. wrote in post #1036509:

Are you talking about a fresh command prompt after you installed?

Yes.

What is the value of PATH?

When I “start command prompt wit ruby”, Path value is:

PATH=C:\Ruby193\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Program

Files\Intel\WiFi\bin;C:\Program Files\Common Files\Ulead Systems\MPEG

When I go to a normal command prompt, the Path value is:

PATH=C:\Ruby193\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Program

Files\Intel\WiFi\bin;C:\Program Files\Common Files\Ulead Systems\MPEG

So C:\Ruby193\bin is in the PATH.

so:

ruby -v

Should work.

Please verify that C:\Ruby193\bin directory contains “ruby.exe” file in
it.

Also, do you have any Antivirus software installed? perhaps something
is blocking Ruby from working properly.


Luis L.

Hussain A. wrote in post #1036449:

I have reinstalled a couple of times now, making sure the option was
checked at the time of installation. Restarting after each uninstall and
reinstall. Still doesn’t work.

Are you talking about a fresh command prompt after you installed?

What is the value of PATH?

I recommend you join RubyInstaller list:

http://groups.google.com/group/rubyinstaller/

And provide the more information about your environment, environment
variables (like PATH, HOME, etc) and other details for the guys be able
to help you.

Is it possible that the problem has to do with the permissions I have on
my machine (I am using my work machine, on which I have limited rights).
It is letting me install Ruby without raising errors though.

RubyInstaller works good in both admin and non-admin set of permissions
so it can work under limited rights without issues.


Luis L.

So C:\Ruby193\bin is in the PATH.

My apologies. When I go to a normal command prompt, the path is:

PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Program
Files\Intel\WiFi\bin;C:\Program Files\Common Files\Ulead Systems\MPEG

So, C:\Ruby193\bin is not in the path. So sorry I managed to paste the
same thing twice in my last post.

so:

ruby -v

Should work.

It works when I ‘start command prompt with Ruby’. Not
otherwise.

Please verify that C:\Ruby193\bin directory contains “ruby.exe” file in
it.

Yes it does.

Also, do you have any Antivirus software installed? perhaps something
is blocking Ruby from working properly.

Definitely have anti-virus…

Thanks!

Hussain A. wrote in post #1036539:

So C:\Ruby193\bin is in the PATH.

My apologies. When I go to a normal command prompt, the path is:

PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Program

Files\Intel\WiFi\bin;C:\Program Files\Common Files\Ulead Systems\MPEG

So, C:\Ruby193\bin is not in the path. So sorry I managed to paste the
same thing twice in my last post.

OK, so have you checked the option that I mentioned before during the
installer?

[x] Add Ruby executables to the PATH

Have you started another command prompt after that?

After you install and check that box again, can you open a new command
prompt and execute the following?

C:\Users\Luis>REG QUERY “HKCU\Environment”

You should see a key in the output like this:
PATH REG_EXPAND_SZ …

What is the output in your case?


Luis L.

Have you tried manually editing the path variable?
Does that work?

What OS are you using?

On WinXP Right click on My computer
Choose “Advanced” tab
Then “Environmental variables”
In the “system variables” list list click on path.

You can view the path variable and you may be able to Edit it from there
to
add “C:\Ruby193\bin” , just don’t change the current ones or you may
break
other things.

But I am guessing you probably don’t have access to change it as it says
“You must be logged on as a member of the administrators group to change
change values”

You maybe able to Create a new User variable that will only work for
your
account.
In the top group (user variables for {accountName}) Try creating a new
variable called “Path” and put “C:\Ruby193\bin” as the value.

That should be appended to the System environment path variable, only
for
your account.

I hope this works for you, sorry if I am leading you astray.

Jaxxa.

You maybe able to Create a new User variable that will only work for
your
account.
In the top group (user variables for {accountName}) Try creating a new
variable called “Path” and put “C:\Ruby193\bin” as the value.

That should be appended to the System environment path variable, only
for
your account.

It worked. Much appreciate the help.

OK, so have you checked the option that I mentioned before during the
installer?

[x] Add Ruby executables to the PATH

Have you started another command prompt after that?

Yes to all

After you install and check that box again, can you open a new command
prompt and execute the following?

C:\Users\Luis>REG QUERY “HKCU\Environment”

You should see a key in the output like this:
PATH REG_EXPAND_SZ …

What is the output in your case?

There was no PATH in the output. However, I followed the steps in
Jaxxa’s response, created a user variable PATH, and that seems to have
sorted things!

Thanks a lot for all your help.

Glad I could help.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs