Ruby Compile.

Discussion in 'Ruby' started by Tridib Bandopadhyay, Oct 22, 2010.

  1. I am running Ruby 1.8.1 on CentOS release 4.8(Final)..

    I have compiled the Ruby and my 'make test' command gives me test
    succeeded.



    Can I run a small ruby code without installing ruby.If so,how to do..

    I tried to run a small program but when trying to run it as

    --ruby calc.rb >>>It shows command not found.

    --
    Posted via http://www.ruby-forum.com/.
     
    Tridib Bandopadhyay, Oct 22, 2010
    #1
    1. Advertising

  2. Tridib Bandopadhyay

    Jeremy Bopp Guest

    On 10/22/2010 10:57 AM, Tridib Bandopadhyay wrote:
    > I am running Ruby 1.8.1 on CentOS release 4.8(Final)..
    >
    > I have compiled the Ruby and my 'make test' command gives me test
    > succeeded.
    >
    >
    >
    > Can I run a small ruby code without installing ruby.If so,how to do..
    >
    > I tried to run a small program but when trying to run it as
    >
    > --ruby calc.rb >>>It shows command not found.


    In the top level of your Ruby source directory should be the compiled
    ruby program. The problem that this path is not in your PATH
    environment variable, so simply invoking ruby as "ruby" will not find
    it. There are a couple of options available to you:

    1) Add the path to the directory containing the ruby program you built
    to your PATH environment variable:
    PATH=/path/to/ruby/source:$PATH
    2) Run ruby using an explicit path to ruby such as:
    /path/to/ruby/source/ruby calc.rb

    There are other variations on these options, but these are the basics.

    -Jeremy
     
    Jeremy Bopp, Oct 22, 2010
    #2
    1. Advertising

  3. Jeremy Bopp wrote in post #956345:
    > On 10/22/2010 10:57 AM, Tridib Bandopadhyay wrote:
    >>
    >> --ruby calc.rb >>>It shows command not found.

    >
    > In the top level of your Ruby source directory should be the compiled
    > ruby program. The problem that this path is not in your PATH
    > environment variable, so simply invoking ruby as "ruby" will not find
    > it. There are a couple of options available to you:
    >
    > 1) Add the path to the directory containing the ruby program you built
    > to your PATH environment variable:
    > PATH=/path/to/ruby/source:$PATH
    > 2) Run ruby using an explicit path to ruby such as:
    > /path/to/ruby/source/ruby calc.rb
    >
    > There are other variations on these options, but these are the basics.
    >
    > -Jeremy



    I am running it on a server of my School....So i didn't get it how to
    do?.

    Secondly when I type ls -lt the latest file which shows is

    rbconfigure.rb

    Regards
    Tridib

    --
    Posted via http://www.ruby-forum.com/.
     
    Tridib Bandopadhyay, Oct 22, 2010
    #3
  4. Tridib Bandopadhyay

    Jeremy Bopp Guest

    On 10/22/2010 11:10 AM, Tridib Bandopadhyay wrote:
    > Jeremy Bopp wrote in post #956345:
    >> On 10/22/2010 10:57 AM, Tridib Bandopadhyay wrote:
    >>>
    >>> --ruby calc.rb >>>It shows command not found.

    >>
    >> In the top level of your Ruby source directory should be the compiled
    >> ruby program. The problem that this path is not in your PATH
    >> environment variable, so simply invoking ruby as "ruby" will not find
    >> it. There are a couple of options available to you:
    >>
    >> 1) Add the path to the directory containing the ruby program you built
    >> to your PATH environment variable:
    >> PATH=/path/to/ruby/source:$PATH
    >> 2) Run ruby using an explicit path to ruby such as:
    >> /path/to/ruby/source/ruby calc.rb
    >>
    >> There are other variations on these options, but these are the basics.
    >>
    >> -Jeremy

    >
    >
    > I am running it on a server of my School....So i didn't get it how to
    > do?.


    The options I listed are about as basic as it gets, I'm afraid. My
    recommendation is that you take the first option. Open your shell on
    the server and enter the following:

    PATH=/path/to/ruby/source:$PATH

    Where /path/to/ruby/source is the full path to the location where you
    extracted the Ruby sources in order to build your version of Ruby.

    > Secondly when I type ls -lt the latest file which shows is
    >
    > rbconfigure.rb


    I'm not sure what you're trying to tell me here. The most current file
    in a directory I don't know about (since you didn't say) doesn't appear
    relevant to you running ruby to process your calc.rb script.

    -Jeremy
     
    Jeremy Bopp, Oct 22, 2010
    #4
  5. On Fri, Oct 22, 2010 at 11:57 AM, Tridib Bandopadhyay
    <> wrote:
    > I am running Ruby 1.8.1 on CentOS release 4.8(Final)..
    >
    > I have compiled the Ruby and my 'make test' command gives me test
    > succeeded.
    >
    >
    >
    > Can I run a small ruby code without installing ruby.If so,how to do..
    >
    > I tried to run a small program but when trying to run it as
    >
    > --ruby calc.rb >>>It shows command not found.
    >
    > --
    > Posted via http://www.ruby-forum.com/.
    >
    >


    try building the ruby source this way so it builds and installs under
    your home folder, you can later just delete this folder without worry

    cd ~
    mkdir -p ruby/local/

    now cd into the source folder where you extracted the ruby source

    NOTE: the use of tilda ~ in the path below, you want to install it
    under your home folder ~/ruby/local/

    /configure --prefix=~/ruby/local
    make
    make test
    make install

    export $PATH=~/ruby/local:$PATH

    now test if you can run ruby with:
    ruby -v

    the export command will only be good for the current session, if you
    want to make it permanent, save it to you bash start up file

    nano ~/.bashrc

    add the line at the bottom of your file

    $PATH=~/ruby/local:$PATH

    save and exit the file

    btw, i am assuming you're using the bash shell. if you still don't
    know what to do ask your sysadmin for help at school

    --
    Kind Regards,
    Rajinder Yadav | DevMentor.org | Do Good! ~ Share Freely

    GNU/Linux: 2.6.35-22-generic
    Kubuntu x86_64 10.10 | KDE 4.5.1
    Ruby 1.9.2p0 | Rails 3.0.1
     
    Rajinder Yadav, Oct 22, 2010
    #5
  6. On Fri, Oct 22, 2010 at 3:03 PM, Rajinder Yadav <> wrote:


    > try building the ruby source this way so it builds and installs under
    > your home folder, you can later just delete this folder without worry
    >
    > cd ~
    > mkdir -p ruby/local/
    >
    > now cd into the source folder where you extracted the ruby source
    >
    > NOTE: the use of tilda ~ in the path below, you want to install it
    > under your home folder ~/ruby/local/
    >
    > ./configure --prefix=~/ruby/local
    > make
    > make test
    > make install
    >
    > export $PATH=~/ruby/local:$PATH


    correction to the path,

    export $PATH=~/ruby/local/bin:$PATH

    > now test if you can run ruby with:
    > ruby -v
    >
    > the export command will only be good for the current session, if you
    > want to make it permanent, save it to you bash start up file
    >
    > nano ~/.bashrc
    >
    > add the line at the bottom of your file
    >
    > $PATH=~/ruby/local:$PATH


    same correction here

    > $PATH=~/ruby/local/bin:$PATH


    >
    > save and exit the file
    >
    > btw, i am assuming you're using the bash shell. if you still don't
    > know what to do ask your sysadmin for help at school
    >


    --
    Kind Regards,
    Rajinder Yadav | DevMentor.org | Do Good! ~ Share Freely

    GNU/Linux: 2.6.35-22-generic
    Kubuntu x86_64 10.10 | KDE 4.5.1
    Ruby 1.9.2p0 | Rails 3.0.1
     
    Rajinder Yadav, Oct 22, 2010
    #6
  7. @Rajinder Yadav

    I don't want to install ruby. I just want to compile it which is done
    for me.

    As its showing test succeeded on Make test command.But i tried a simple
    ruby code as

    puts 1+2

    with file named calc.rb and tried to run it with command.

    ruby calc.rb>>> Its telling me command not found.
    ___________________________________________________________
    Secondly I tried what you said in my home directory within the server.

    /configure --prefix=~/ruby/local

    Its telling me.

    configure: error: expected an absolute directory name for --prefix:
    ~/ruby/local

    Regards.

    Tridib

    --
    Posted via http://www.ruby-forum.com/.
     
    Tridib Bandopadhyay, Oct 25, 2010
    #7
  8. Tridib Bandopadhyay

    Ammar Ali Guest

    On Mon, Oct 25, 2010 at 7:40 PM, Tridib Bandopadhyay <> wrote:
    > @Rajinder Yadav
    >
    > I don't want to install ruby. I just want to compile it which is done
    > for me.
    >
    > As its showing test succeeded on Make test command.But i tried a simple
    > ruby code as
    >
    > puts 1+2
    >
    > with file named calc.rb and tried to run it with command.
    >
    > ruby calc.rb>>> Its telling me command not found.


    Yes. You didn't install ruby, you just compiled it. The system can't
    find the ruby command you compiled.


    > ___________________________________________________________
    > Secondly I tried what you said in my home directory within the server.
    >
    > ./configure --prefix=~/ruby/local
    >
    > Its telling me.
    >
    > configure: error: expected an absolute directory name for --prefix:
    > ~/ruby/local


    The suggestion is good. You need to replace the '~' in the path with
    the path of your home directory:

    ./configure --prefix=/home/your-user-name/ruby/local

    You might also need to create the path for 'ruby/local' with:

    mkdir -p ~/ruby/local

    Rajinder's comments tell you how to add that special path (the system
    doesn't know to look there) to the system's list of places to look for
    commands, so you can just type:

    $ ruby 'puts 1 + 2'

    instead of:

    $ /home/your-user-name/ruby/local/bin/ruby

    HTH,
    Ammar
     
    Ammar Ali, Oct 25, 2010
    #8
  9. Ammar Ali wrote in post #956972:


    >
    > The suggestion is good. You need to replace the '~' in the path with
    > the path of your home directory:
    >
    > ./configure --prefix=/home/your-user-name/ruby/local
    >
    > Ammar


    Thank You It is working now.....It shows config.status: creating
    Makefile


    Now what I have to do?..

    Regards

    Tridib

    --
    Posted via http://www.ruby-forum.com/.
     
    Tridib Bandopadhyay, Oct 25, 2010
    #9
  10. DaShiell, Jude T. CIV NAVAIR 1490, 1, 26 wrote in post #956977:
    > First if you built in /usr/local/src, /usr/local/src/ruby-1.9.2/bin is
    > likely to hold your ruby executable. So be in the same directory then
    > run ./ruby calc.rb with calc.rb being temporarily placed in that bin
    > directory. I think you'll have your expected results once you do that.
    > Hth.


    Thank You very much...I got the result I was expecting....

    Regards

    Tridib

    --
    Posted via http://www.ruby-forum.com/.
     
    Tridib Bandopadhyay, Oct 25, 2010
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nagaraj
    Replies:
    1
    Views:
    873
    Lionel B
    Mar 1, 2007
  2. timjowers
    Replies:
    7
    Views:
    4,353
    heyjude
    Feb 2, 2011
  3. Replies:
    1
    Views:
    451
    Cowboy \(Gregory A. Beamer\)
    Apr 11, 2008
  4. Carter
    Replies:
    2
    Views:
    509
    Carter
    Mar 4, 2009
  5. fAnSKyer
    Replies:
    2
    Views:
    534
    Alf P. Steinbach
    Jun 7, 2009
Loading...

Share This Page