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.

6
  • What happens when you run ruby on a terminal?
    – muru
    Dec 9, 2014 at 11:14
  • to run ruby, what am I write on terminal ? First time using this.
    – Nishant
    Dec 9, 2014 at 11:18
  • Write ruby and press enter. Ruby doesn't provide a prompt, so don't be surprised if you get a blank line.
    – muru
    Dec 9, 2014 at 11:18
  • Only blank line shows with pointer blinking. Nothing else.
    – Nishant
    Dec 9, 2014 at 11:19
  • And if you run irb?
    – muru
    Dec 9, 2014 at 11:19

2 Answers 2

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> 
11
  • I have use both the condition & I have got same result too. IT means ruby is fully configured in my system.
    – Nishant
    Dec 9, 2014 at 11:27
  • @samzha I am no ruby expert, but I'd say that ruby seems to be working.
    – muru
    Dec 9, 2014 at 11:29
  • actually I am working on a projects where SCSS file is used to handle the css. So for using SCSS I have to know how to use Ruby on rails. Without Ruby on rails I am unable to work on this. So for ruby command prompt which one is correct.
    – Nishant
    Dec 9, 2014 at 11:30
  • @samzha That I cannot say. You should ask on Stack Overflow.
    – muru
    Dec 9, 2014 at 11:31
  • But in stack overflow my question is offtopic. My question is that how can I open Ruby Command Line in ubuntu. How to use is the another thing. I want to know how to open.
    – Nishant
    Dec 9, 2014 at 11:32
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
3
  • Thanks @Gordon. It mean that for Ruby command line I have configure the default terminal to Ruby cmd line.
    – Nishant
    Dec 9, 2014 at 12:43
  • Please help me in one thing that like normal terminal if I want to goto my htdocs project folder I can go through > cd /opt/lampp/htdocs/myproject. Then in Ruby Command line i.e. irb(main):001:0> how can I reach my path. Please help @Gordon.
    – Nishant
    Dec 9, 2014 at 12:46
  • If you mean you have set your terminal session so that it uses irb instead of bash, that would be very unusual, though may well work OK. Ruby is a programming language rather than a working environment, but if that works for you... I'm not an authority on Ruby, but I believe you want Dir.chdir("pathname").
    – Gordon
    Dec 10, 2014 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.