How to get "irb1.8" using Ruby1.8 instead of Ruby1.9.1?

Hi, in Debian I’ve ruby1.8 (/usr/bin/ruby1.8) and irb1.8 installed as
DEB
packages, and Ruby 1.9.1 installed from sources, so /usr/bin/ruby is
Ruby
1.9.1.

When I run “irb1.8” it uses Ruby 1.9.1:

~$ irb1.8
irb> RUBY_VERSION
“1.9.1”

How could I get irb1.8 using Ruby 1.8? I see no options using irb
arguments,
do I miss something?

Thanks.

What you are saying is very likely incorrect. You or someone else must
have screwed up the links to ruby and irb in {{ /usr/bin }}. If you do
the following you should get a similar result as I will list below:

$ cd /usr/bin/
$ ls -l ruby*
lrwxrwxrwx 1 root root 7 2009-02-27 13:52 ruby -> ruby1.8
-rwxr-xr-x 1 root root 3564 2008-10-09 20:19 ruby1.8
lrwxrwxrwx 1 root root 7 2008-10-28 12:51 ruby1.8-old-LINK ->
ruby1.8
-rwxr-xr-x 1 root root 3676 2008-01-24 07:02 ruby1.9
-rwxr-xr-x 1 root root 6320 2007-12-07 05:09
ruby-glade-create-template

$ ls -l irb*
lrwxrwxrwx 1 root root 6 2008-10-28 13:15 irb -> irb1.9
-rwxr-xr-x 1 root root 376 2008-10-09 20:14 irb1.8
-rwxr-xr-x 1 root root 376 2008-01-24 06:54 irb1.9

As you see {{ ruby }} and {[ irb }} should be symbolic links to their
respective version binaries. To change the the behavior you can change
these links.

For instance If I wish to make my {{ irb }} to point to {{ 1.8 irb }}, I
would do the following as {{ root }} or with the help of {{ sudo }}:

  1. mv /usr/irb /usr/irb.old
  2. ln -s /usr/bin/irb1.8 /usr/irb

If you are not sure you understand the above procedure I suggest you do
not do anything on your own without some more help from people on the
forum. For starters you should post the results of the following here:

$ cd /usr/bin/
$ ls -l ruby*
$ ls -l irb*

Oops, I made a mistake above. Here is the correction:

For instance If I wish to make my {{ irb }} to point to {{ 1.8 irb }}, I
would do the following as {{ root }} or with the help of {{ sudo }}:

  1. mv /usr/bin/irb /usr/irb.old
  2. ln -s /usr/bin/irb1.8 /usr/bin/irb

Iñaki Baz C. wrote:

/usr/bin$ ls -l ruby*
-rwxr-xr-x 1 root root 5,4M 2009-03-30 22:47 ruby*
-rwxr-xr-x 1 root root 6,1K 2009-01-25 03:04 ruby1.8*
lrwxrwxrwx 1 root root 4 2009-03-30 22:55 ruby1.9 -> ruby*

Your symbolic link here is clearly wrong. If you didn’t make a mistake
writing I am sure it is the source of all your problems. {{ ruby }}
should point to {{ ruby1.9 }} and not as is shown in your post above.

The correct link should be:

lrwxrwxrwx 1 root root    4 2009-03-30 22:55 ruby -> ruby1.9

El Domingo 05 Abril 2009, Igor P. escribió:

-rwxr-xr-x 1 root root 3676 2008-01-24 07:02 ruby1.9
-rwxr-xr-x 1 root root 6320 2007-12-07 05:09
ruby-glade-create-template

$ ls -l irb*
lrwxrwxrwx 1 root root 6 2008-10-28 13:15 irb -> irb1.9
-rwxr-xr-x 1 root root 376 2008-10-09 20:14 irb1.8
-rwxr-xr-x 1 root root 376 2008-01-24 06:54 irb1.9

This is not what I clearly explained in my mail.
As I explained, I’ve Ruby1.8 and irb1.8 installed as DEB package, but I
installed Ruby1.9.1 from sources setting “–prefix=/usr/bin”, getting:

/usr/bin$ ls -l ruby*
-rwxr-xr-x 1 root root 5,4M 2009-03-30 22:47 ruby*
-rwxr-xr-x 1 root root 6,1K 2009-01-25 03:04 ruby1.8*
lrwxrwxrwx 1 root root 4 2009-03-30 22:55 ruby1.9 -> ruby*

/usr/bin$ ls -l irb*
lrwxrwxrwx 1 root root 6 2009-03-28 14:16 irb -> irb1.8*
-rwxr-xr-x 1 root root 314 2009-03-30 22:48 irb1.8*

This is:

  • /usr/bin/ruby1.8 is the executable of Ruby 1.8.
  • /usr/bin/ruby is the executable of Ruby 1.9.1.
  • /usr/bin/ruby1.9 is a softlink to /usr/bin/ruby.

As you see {{ ruby }} and {[ irb }} should be symbolic links to their
respective version binaries. To change the the behavior you can change
these links.

Not in my case as I’ve explained above.

For instance If I wish to make my {{ irb }} to point to {{ 1.8 irb }}, I
would do the following as {{ root }} or with the help of {{ sudo }}:

  1. mv /usr/irb /usr/irb.old
  2. ln -s /usr/bin/irb1.8 /usr/irb

If you are not sure you understand the above procedure I suggest you do
not do anything on your own without some more help from people on the
forum. For starters you should post the results of the following here:

Sorry, but I do really know what a symbolic link is. Please re-read my
first
mail before assuming I’m a starter.

However I found my problem.

irb1.9 exists after compiling Ruby1.9.1 in
/usr/src/ruby1.9.1-xxx/bin/irb

In /usr/bin I had:

  • /usr/bin/irb --> /usr/bin/irb1.8
  • /usr/bin/irb1.8

So when I installed Ruby1.9.1, /usr/bin/irb was replaced by the Ruby1.9
version, this is, /usr/bin/irb1.8 pointed then to irb compiled in
Ruby1.9.1.

I’ve solved it by copying the compiled irb (Ruby1.9) as /usr/bin/irb1.9
and
re-installing the Debian irb1.8 package, so /usr/bin/irb1.8 is replaced
again.

Now:

~# irb1.8
irb(main):001:0> RUBY_VERSION
“1.8.7”

~# irb1.9
irb(main):001:0> RUBY_VERSION
“1.9.1”

On Sat, 04 Apr 2009 14:47:27 -0500, Iñaki Baz C. wrote:

How could I get irb1.8 using Ruby 1.8? I see no options using irb
arguments, do I miss something?

Thanks.

Please tell me what the shebang in irb1.8 is, by running

head /usr/bin/irb1.8

(On my system, it says #!/usr/bin/ruby1.8, so this whole situation
you’re
in should be impossible.)

By the way, the better solution would have been to install Ruby 1.9.1
from experimental, rather than from the upstream sources. I’m not sure
what they’re waiting for to put it in unstable.

–Ken

El Domingo 05 Abril 2009, Ken B. escribió:

Please tell me what the shebang in irb1.8 is, by running

head /usr/bin/irb1.8

(On my system, it says #!/usr/bin/ruby1.8, so this whole situation you’re
in should be impossible.)

Thanks. As I’ve explained in this thread, I had Ruby1.8 installed as DEB
package (so irb was a link to irb1.8).
When compiling and installing Ruby1.9.1 from sources, it created
/usr/bin/ruby
and /usr/bin/irb.
But it’s strange since /usr/bin/irb was a softlink and after Ruby 1.9.1
install it remains being a softlink to irb1.8, but irb1.8 is now a copy
of the
installed irb (Ruby 1.9.1).

By the way, the better solution would have been to install Ruby 1.9.1
from experimental, rather than from the upstream sources. I’m not sure
what they’re waiting for to put it in unstable.

I’m using it in Debian Etch and Ubuntu Jaunty. Ruby1.9.1 doesn’t no
exist in
those distributions. Installing Ruby 1.9.1 from experimental in my
Debian Etch
would require upgrading my system to sid/experimental and I cannot do
it.

Thanks a lot for your help.

On Sun, Apr 5, 2009 at 8:29 AM, Iñaki Baz C. [email protected]
wrote:

When compiling and installing Ruby1.9.1 from sources, it created
/usr/bin/ruby
and /usr/bin/irb.
But it’s strange since /usr/bin/irb was a softlink and after Ruby 1.9.1
install it remains being a softlink to irb1.8, but irb1.8 is now a copy of
the
installed irb (Ruby 1.9.1).

The Debian packaging system relies on users not installing stuff in the
same
places that the packager does. /usr/bin is one of those places.

When you are installing source on a Debian based system (which would
include
Ubuntu) you need to put it somewhere else., like /usr/local/bin, so
instead
of just
./configure
make
sudo make install

you need to do something like

./configure --prefix=/usr/local/ruby1.9
make
sudo make install

I think you need to somehow force the system to reinstall the ruby 1.8
package(s), then install 1.9 from source to a safe place.

El Domingo 05 Abril 2009, Igor P. escribió:

Iñaki Baz C. wrote:

/usr/bin$ ls -l ruby*
-rwxr-xr-x 1 root root 5,4M 2009-03-30 22:47 ruby*
-rwxr-xr-x 1 root root 6,1K 2009-01-25 03:04 ruby1.8*
lrwxrwxrwx 1 root root 4 2009-03-30 22:55 ruby1.9 -> ruby*

Your symbolic link here is clearly wrong. If you didn’t make a mistake
writing I am sure it is the source of all your problems. {{ ruby }}
should point to {{ ruby1.9 }} and not as is shown in your post above.

That makes sense, but when I installed Ruby1.9.1 from sources, the
binary it
creates was:
/usr/bin/ruby

and I did a symbolic link:
/usr/bin/ruby1.9 --> /usr/bin/ruby

(yes, I could rename ruby as ruby1.9 and create a link “ruby”).

El Domingo 05 Abril 2009, Rick DeNatale escribió:

The Debian packaging system relies on users not installing stuff in the
same places that the packager does. /usr/bin is one of those places.

When you are installing source on a Debian based system (which would
include Ubuntu) you need to put it somewhere else., like /usr/local/bin

Yes, you are completely right. I expected installation from sources to
create
ruby1.9 and irb1.9 by default, so I didn0t care about using /usr/bin
directory, but I was wrong.

I think you need to somehow force the system to reinstall the ruby 1.8
package(s), then install 1.9 from source to a safe place.

Yes, that’s what I did so irb1.8 was correctly replaced again.

Thanks a lot.

On Sun, Apr 5, 2009 at 9:53 AM, Rick DeNatale
[email protected]wrote:

make

An afterthought, that configure command should probably be
./configure --prefix=/usr/local/ruby1.9 --program-suffix=1.9

the second option will turn the ruby, irb and other executables into
ruby1.9, irb1.9 etc rather than just
ruby, irb…


Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

Iñaki Baz C. wrote:

When compiling and installing Ruby1.9.1 from sources, it created
/usr/bin/ruby
and /usr/bin/irb.

The above clearly shows that the compilation messed up the links in your
/usr/bin. Different versions of ruby and irb binaries must be stored as
/usr/bin/ruby1.8, /usr/bin/irb1.8 and /usr/bin/ruby1.9, /usr/bin/irb1.9.
On the other hand /usr/bin/ruby and /usr/bin/irb must be links and not
binaries. Your compilation removed the links and installed binaries in
their place.

The solution to your problem is identification of the versions of the
binaries and name them correctly as explained above. Remove or move away
the old /usr/bin/ruby and /usr/bin/irb.

Linking a version to a name without the version numbers is optional, but
when you do the links, that must be done consistently and most
importantly in the right direction (make sure you always link the number
name (first argument) to non-number name (second argument) in the link
command: i.e. {{ ln -s /usr/bin/ruby1.9 /use/bin/ruby }}). Of course the
non-name argument must not exist (must be removed) before you run the {{
ln -s … }}, otherwise the link command will fail.

For your convenience you can create a script to relink your binaries to
whichever version you like. Following is the link_ruby file I use:

#!/bin/bash

if [ $# -eq 0 ]; then
version=9
else
case $1 in
-h|-H) echo “usage: $(basename $0) -8|-9 | [-h]”; exit;;
8|-8) version=8;;
9|-9) version=9;;
*) echo Illegal argument; exit;;
esac
fi

if [ $version = 9 ] ;then
echo Currently your ruby version is 1.9
rm /usr/bin/ruby
ln -s /usr/bin/ruby1.9 /usr/bin/ruby
rm /usr/bin/irb
ln -s /usr/bin/irb1.9 /usr/bin/irb
else
echo Currently your ruby version is 1.8
rm /usr/bin/ruby
ln -s /usr/bin/ruby1.8 /usr/bin/ruby
rm /usr/bin/irb
ln -s /usr/bin/irb1.8 /usr/bin/irb
fi

El Domingo 05 Abril 2009, Igor P. escribió:

their place.

The solution to your problem is identification of the versions of the
binaries and name them correctly as explained above. Remove or move away
the old /usr/bin/ruby and /usr/bin/irb.

Thanks, already solvedby reinstalling Ruby 1.9.1 from sources with
options:

./configure --prefix=/usr/local/ --program-suffix=1.9

Then I get:

/usr/local/bin# ll
-rwxr-xr-x 1 root root 4,4K 2009-04-05 16:49 erb1.9*
-rwxr-xr-x 1 root root 791 2009-04-05 16:49 gem1.9*
-rwxr-xr-x 1 root root 323 2009-04-05 16:49 irb1.9*
-rwxr-xr-x 1 root root 1,3K 2009-04-05 16:49 rake1.9*
-rwxr-xr-x 1 root root 415 2009-04-05 16:49 rdoc1.9*
-rwxr-xr-x 1 root root 78 2009-04-05 16:49 ri1.9*
-rwxr-xr-x 1 root root 5,4M 2009-04-05 16:48 ruby1.9*
-rwxr-xr-x 1 root root 252 2009-04-05 16:49 testrb1.9*

And later I do symbolic links from /usr/bin to there, i.e:

/usr/bin/ruby --> /usr/local/bin/ruby1.9

Thanks.

El Domingo 05 Abril 2009, Rick DeNatale escribió:

An afterthought, that configure command should probably be
./configure --prefix=/usr/local/ruby1.9 --program-suffix=1.9

the second option will turn the ruby, irb and other executables into
ruby1.9, irb1.9 etc rather than just
ruby, irb…

Really interesting and useful information. Thanks.

On Sun, 05 Apr 2009 07:29:36 -0500, Iñaki Baz C. wrote:

Ruby1.9.1 from sources, it created /usr/bin/ruby and /usr/bin/irb.
But it’s strange since /usr/bin/irb was a softlink and after Ruby 1.9.1
install it remains being a softlink to irb1.8, but irb1.8 is now a copy
of the installed irb (Ruby 1.9.1).

So you’re saying that when you installed irb from source, it overwrote
the TARGET of the /usr/bin/irb link rather than the /usr/bin/irb link
itself. That’s really wierd. The solution would be to
“apt-get install --reinstall irb1.8”, but note that you’ll probably lose
irb 1.9 by doing that. (See other posts for information about better
ways
to arrange how things are set up on your system.)

–Ken

El Domingo 05 Abril 2009, Ken B. escribió:

Thanks. As I’ve explained in this thread, I had Ruby1.8 installed as DEB
package (so irb was a link to irb1.8). When compiling and installing
Ruby1.9.1 from sources, it created /usr/bin/ruby and /usr/bin/irb.
But it’s strange since /usr/bin/irb was a softlink and after Ruby 1.9.1
install it remains being a softlink to irb1.8, but irb1.8 is now a copy
of the installed irb (Ruby 1.9.1).

So you’re saying that when you installed irb from source, it overwrote
the TARGET of the /usr/bin/irb link rather than the /usr/bin/irb link
itself. That’s really wierd.

Yes, wierd and really strange, I can’t imagine how a “make install”
process
can do that instead of overwritting the softlink “irb” as a new binary.

The solution would be to
“apt-get install --reinstall irb1.8”, but note that you’ll probably lose
irb 1.9 by doing that. (See other posts for information about better ways
to arrange how things are set up on your system.)

Yes, already done and fixed :wink:

Thanks.