Ruby Compile.

  • Thread starter Tridib Bandopadhyay
  • Start date
T

Tridib Bandopadhyay

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

Jeremy Bopp

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
 
T

Tridib Bandopadhyay

Jeremy Bopp wrote in post #956345:
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
 
J

Jeremy Bopp

Jeremy Bopp wrote in post #956345:


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
 
R

Rajinder Yadav

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.

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
 
R

Rajinder Yadav

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
 
T

Tridib Bandopadhyay

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

Ammar Ali

@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
 
T

Tridib Bandopadhyay

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
 
T

Tridib Bandopadhyay

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top