9

I have Installed Ruby On Rails of version 2.1.3p242 on my system. But I can't findout the ruby command line. I have searched but not found.

I have try to to check through

man ruby : Show some details

man rail : "See 'man 7 undocumented' for help when manual pages are not available."

May anybody help me to open the Ruby cmd line.

Nishant
  • 211

2 Answers2

14

There are two ways of interactively using ruby on the command line (like running python or nodejs, for example):

Simply run ruby:

$ ruby
print "hello world\n"

Then press CtrlD. You will see:

hello world

The easier way is Interactive Ruby (irb):

$ irb
irb(main):001:0> print "hello\n"
hello
=> nil
irb(main):002:0> 
muru
  • 207,228
2

If you want a "Ruby command line" then you want irb

The command ruby is the non-command-line version. You can use that from the command line in several ways(*), but it is not a command line in itself.

As you didn't find irb, I guess you may not know about the command apropos The word means "pertinent information about" and typing

apropos ruby

will list a number of ruby-related things, including irb.

The argument for the command man usually must match the command or whatever exactly, so

man rail

would not find a manual page, even if there was one, man rails normally would, but I believe there is no rails man-page and you have to refer to the Ruby documentation for that.

(*) The usual Unix methods, e.e.:

  • As shown in the answer above.
  • echo 'print "hello world\n"' | ruby
  • ruby < my-ruby-prob.rb
  • The 'hereis' and 'shebang (#!) methods
Gordon
  • 613
  • 2
  • 7
  • 12