Ruby Compile

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.

On 10/22/2010 10:57 AM, Tridib B. 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

Jeremy B. wrote in post #956345:

On 10/22/2010 10:57 AM, Tridib B. 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

On 10/22/2010 11:10 AM, Tridib B. wrote:

  1. Add the path to the directory containing the ruby program you built
    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

On Fri, Oct 22, 2010 at 11:57 AM, Tridib B.
[email protected] wrote:

–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 Y. | 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

On Fri, Oct 22, 2010 at 3:03 PM, Rajinder Y. [email protected]
wrote:

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

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

correction to the path,

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

$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 Y. | 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 Y.

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

On Mon, Oct 25, 2010 at 7:40 PM, Tridib B.
[email protected] wrote:

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 A. 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

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.

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

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