Getting Started With Development

I’m new to Ruby Development. I downloaded source from Github, but
couldn’t
build it. Can somebody tell me where I can download a ruby-lang source
that
can be compiled and run. How should I compile and run it on Linux?

Ruby is often installed on linux, or can be easily installed with the
package manager. Personally, I prefer to build and install from the
source, like this:

tar xzf /opt/src/ruby-2.0.0-p195.tar.gz

cd ruby-2.0.0-p195

./configure

make

sudo make install

irb

irb(main):001:0> RUBY_VERSION
=> “2.0.0”
irb(main):002:0> exit

On Tue, Jun 11, 2013 at 4:46 AM, Chamila Wijayarathna <
[email protected]> wrote:

I’m new to Ruby Development. I downloaded source from Github, but couldn’t
build it. Can somebody tell me where I can download a ruby-lang source that
can be compiled and run. How should I compile and run it on Linux?

It helps if you explain how you tried to build it and why it didn’t work
(what was the error?)

-Josh

Hello,

On 11 Ιουν 2013, at 11:46 , Chamila Wijayarathna
[email protected] wrote:

I’m new to Ruby Development. I downloaded source from Github, but couldn’t build
it. Can somebody tell me where I can download a ruby-lang source that can be
compiled and run. How should I compile and run it on Linux?

I’d like to use RVM ( http://rvm.io ) but if you tell us which version
of linux are you running and what exactly do you want to do, we might be
of better assistance :slight_smile:


Chamila Dilshan Wijayarathna,
SMIEEE, SMIESL,
Undergraduate,
Department of Computer Science and Engineering,
University of Moratuwa.

Panagiotis (atmosx) Atmatzidis

email: [email protected]
URL: http://www.convalesco.org
GnuPG ID: 0x1A7BFEC5
gpg --keyserver pgp.mit.edu --recv-keys 1A7BFEC5

I’m using Ubuntu 11.10.

Panagiotis A. wrote in post #1112049:

I’d like to use RVM ( http://rvm.io ) but if you tell us which version
of linux are you running and what exactly do you want to do, we might be
of better assistance :slight_smile:

Panagiotis (atmosx) Atmatzidis

email: [email protected]
URL: http://www.convalesco.org
GnuPG ID: 0x1A7BFEC5
gpg --keyserver pgp.mit.edu --recv-keys 1A7BFEC5

Per-erik Martin wrote in post #1112021:

Ruby is often installed on linux, or can be easily installed with the
package manager. Personally, I prefer to build and install from the
source, like this:

tar xzf /opt/src/ruby-2.0.0-p195.tar.gz

cd ruby-2.0.0-p195

./configure

I’m okay up to this point. But When I tried to run make, I’m getting
error saying “Executable host Ruby is required”.

make

sudo make install

irb

irb(main):001:0> RUBY_VERSION
=> “2.0.0”
irb(main):002:0> exit

Subject: Re: Getting Started With Development
Date: mer 12 giu 13 03:44:55 +0900

Quoting Chamila W. ([email protected]):

error saying “Executable host Ruby is required”.
Compilation of Ruby in the normal way requires a pre-existing ruby
interpreter. Maybe there is a way to compile from scratch - I do not
know. What I generally do on new machines (I use Debian) is first load
Debian’s package with

apt-get install ruby

After compiling/installing (under /usr/local as default), you can do

apt-get purge ruby

and happily use your self-compiled interpreter plus utilities.

Remember to install the dev package of libreadline if you want to have
irb command history. Do that before running ./configure.

Carlo

Thank you for helping.
I’m hoping to do changes to source and test them. Can I do this after
installing as you mentioned. How can I build after doing some change to
the code?

Carlo E. Prelz wrote in post #1112089:

Subject: Re: Getting Started With Development
Date: mer 12 giu 13 03:44:55 +0900

Quoting Chamila W. ([email protected]):

error saying “Executable host Ruby is required”.
Compilation of Ruby in the normal way requires a pre-existing ruby
interpreter. Maybe there is a way to compile from scratch - I do not
know. What I generally do on new machines (I use Debian) is first load
Debian’s package with

apt-get install ruby

After compiling/installing (under /usr/local as default), you can do

apt-get purge ruby

and happily use your self-compiled interpreter plus utilities.

Remember to install the dev package of libreadline if you want to have
irb command history. Do that before running ./configure.

Carlo

Chamila W. wrote in post #1112078:

Per-erik Martin wrote in post #1112021:

Ruby is often installed on linux, or can be easily installed with the
package manager. Personally, I prefer to build and install from the
source, like this:

tar xzf /opt/src/ruby-2.0.0-p195.tar.gz

cd ruby-2.0.0-p195

./configure

I’m okay up to this point. But When I tried to run make, I’m getting
error saying “Executable host Ruby is required”.

Make sure that you are using the right source tar ball. The ones you
find here:
http://www.ruby-lang.org/en/
should not require a preinstalled ruby for boot strapping.

Subject: Re: Getting Started With Development
Date: mer 12 giu 13 04:53:29 +0900

Quoting Chamila W. ([email protected]):

Thank you for helping.
I’m hoping to do changes to source and test them. Can I do this after
installing as you mentioned. How can I build after doing some change to
the code?

Once you have a running ruby, compilation works OK. Just do a
make. Keep in mind that the first executable found is generally the
one under /usr/local/bin. Check your PATH. After you have done make
install, the last interpreter you compiled will be used for further
compilations.

If you want to see the commands that are executed during make, you can
type

make V=1

Good luck with your changes… :wink:

Carlo

Carlo E. Prelz wrote in post #1112089:

Subject: Re: Getting Started With Development
Date: mer 12 giu 13 03:44:55 +0900

Quoting Chamila W. ([email protected]):

error saying “Executable host Ruby is required”.
Compilation of Ruby in the normal way requires a pre-existing ruby
interpreter. Maybe there is a way to compile from scratch - I do not
know. What I generally do on new machines (I use Debian) is first load
Debian’s package with

apt-get install ruby installs Ruby 1.8.7, but I need to compile Ruby
2.0.0- ,Is it okay to use Ruby 1.8.7 as executable host?

apt-get install ruby

After compiling/installing (under /usr/local as default), you can do

apt-get purge ruby

and happily use your self-compiled interpreter plus utilities.

Remember to install the dev package of libreadline if you want to have
irb command history. Do that before running ./configure.

Carlo

Subject: Re: Getting Started With Development
Date: mer 12 giu 13 10:23:40 +0900

Quoting Chamila W. ([email protected]):

apt-get install ruby installs Ruby 1.8.7, but I need to compile Ruby
2.0.0- ,Is it okay to use Ruby 1.8.7 as executable host?

Yes. For what needs to be done while compiling, 1.8 is enough.

Carlo

I tried this also, it gives the same error “Executable host Ruby is
required”.

Make sure that you are using the right source tar ball. The ones you
find here:
Ruby Programming Language
should not require a preinstalled ruby for boot strapping.

Carlo E. Prelz wrote in post #1112183:

Subject: Re: Getting Started With Development
Date: mer 12 giu 13 10:23:40 +0900

Quoting Chamila W. ([email protected]):

apt-get install ruby installs Ruby 1.8.7, but I need to compile Ruby
2.0.0- ,Is it okay to use Ruby 1.8.7 as executable host?

But it gives errors for new features in Ruby 2.0 that was not in early
versions like “p %i{hurray huzzah whoop}”.

Yes. For what needs to be done while compiling, 1.8 is enough.

Carlo

Subject: Re: Getting Started With Development
Date: mer 12 giu 13 11:03:35 +0900

Quoting Chamila W. ([email protected]):

But it gives errors for new features in Ruby 2.0 that was not in early
versions like “p %i{hurray huzzah whoop}”.

Do not worry. The interpreter is not asked to do anything like “p
%i{hurray huzzah whoop}” while compiling a new interpreter. As soon as
the new interpreter is ready, it will be used instead of the old one
for subsequent tasks.

Carlo

Carlo E. Prelz wrote in post #1112185:

Subject: Re: Getting Started With Development
Date: mer 12 giu 13 11:03:35 +0900

Quoting Chamila W. ([email protected]):

But it gives errors for new features in Ruby 2.0 that was not in early
versions like “p %i{hurray huzzah whoop}”.

What do you mean by new interpreter is ready? I want to check some new
features in Ruby 2.0. i followed steps you suggested. I can’t understand
if I’m getting results from ruby I installed using apt-get or using ruby
I build using source code.

Do not worry. The interpreter is not asked to do anything like “p
%i{hurray huzzah whoop}” while compiling a new interpreter. As soon as
the new interpreter is ready, it will be used instead of the old one
for subsequent tasks.

Carlo

Subject: Re: Getting Started With Development
Date: gio 13 giu 13 12:08:36 +0900

Quoting Chamila W. ([email protected]):

What do you mean by new interpreter is ready? I want to check some new
features in Ruby 2.0. i followed steps you suggested. I can’t understand
if I’m getting results from ruby I installed using apt-get or using ruby
I build using source code.

I mean that the interpreter in /usr/bin (the one installed by
debian/ubuntu) is not used if there is one in /usr/local/bin
(installed by you). This is because, at least in default settings,
/usr/local/bin appears before /usr/bin in PATH.

If you want to be sure that you are not using the old interpreter,
after you have done make install, remove the ubuntu package, as I
already mentioned in a previous msg.

In all cases, you may know what you are running by typing

ruby -v

Another command you may use is

which ruby

which prints out the path of the first executable with the name ‘ruby’
found in your PATH. If you type

ls -l which ruby

you can see if the executable you run is recent or not.

Carlo

I saved project I downloaded at /home/chamila/ruby/rr/ruby and compiled
it. Should I do that at /usr/local/bin ?

I mean that the interpreter in /usr/bin (the one installed by
debian/ubuntu) is not used if there is one in /usr/local/bin
(installed by you). This is because, at least in default settings,
/usr/local/bin appears before /usr/bin in PATH.

If you want to be sure that you are not using the old interpreter,
after you have done make install, remove the ubuntu package, as I
already mentioned in a previous msg.

In all cases, you may know what you are running by typing

when I tried ruby -v it gives the output as ruby 1.8.7.
which ruby gives output /usr/local/bin/ruby.
But when I run RUBY_VERSION in irb it gave 2.1.0 and irb successfully
execute p %i{hurray huzzah whoop} which I couldn’t executed using ruby.

ruby -v

Another command you may use is

which ruby

which prints out the path of the first executable with the name ‘ruby’
found in your PATH. If you type

ls -l which ruby

you can see if the executable you run is recent or not.

Carlo

This is what I’m getting when running ruby and irb, same statements get
different results.

Carlo E. Prelz wrote in post #1112089:

Subject: Re: Getting Started With Development
Date: mer 12 giu 13 03:44:55 +0900

Quoting Chamila W. ([email protected]):

error saying “Executable host Ruby is required”.
Compilation of Ruby in the normal way requires a pre-existing ruby
interpreter. Maybe there is a way to compile from scratch - I do not
know. What I generally do on new machines (I use Debian) is first load
Debian’s package with

This works for me in Ubuntu? It works fine. Do I have to follow same
steps in MAC?

apt-get install ruby

After compiling/installing (under /usr/local as default), you can do

apt-get purge ruby

and happily use your self-compiled interpreter plus utilities.

Remember to install the dev package of libreadline if you want to have
irb command history. Do that before running ./configure.

Carlo