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

  • Thread starter Iñaki Baz Castillo
  • Start date
I

Iñaki Baz Castillo

Hi, in Debian I've ruby1.8 (/usr/bin/ruby1.8) and irb1.8 installed as DEB=20
packages, and Ruby 1.9.1 installed from sources, so /usr/bin/ruby is Ruby=20
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=
,=20
do I miss something?

Thanks.

=2D-=20
I=C3=B1aki Baz Castillo <[email protected]>
 
I

Igor Pirnovar

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*
 
I

Igor Pirnovar

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

Iñaki Baz Castillo

El Domingo 05 Abril 2009, Igor Pirnovar escribi=C3=B3:
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

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=20
installed Ruby1.9.1 from sources setting "--prefix=3D/usr/bin", getting:

/usr/bin$ ls -l ruby*
=2Drwxr-xr-x 1 root root 5,4M 2009-03-30 22:47 ruby*
=2Drwxr-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*
=2Drwxr-xr-x 1 root root 314 2009-03-30 22:48 irb1.8*


This is:
=2D /usr/bin/ruby1.8 is the executable of Ruby 1.8.
=2D /usr/bin/ruby is the executable of Ruby 1.9.1.
=2D /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 fi=
rst=20
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:
=2D /usr/bin/irb --> /usr/bin/irb1.8
=2D /usr/bin/irb1.8

So when I installed Ruby1.9.1, /usr/bin/irb was replaced by the Ruby1.9=20
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=
=20
re-installing the Debian irb1.8 package, so /usr/bin/irb1.8 is replaced aga=
in.

Now:

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

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


=2D-=20
I=C3=B1aki Baz Castillo <[email protected]>
 
I

Igor Pirnovar

Iñaki Baz Castillo said:
/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
 
I

Iñaki Baz Castillo

El Domingo 05 Abril 2009, Igor Pirnovar escribi=C3=B3:
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 i=
t=20
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").


=2D-=20
I=C3=B1aki Baz Castillo <[email protected]>
 
I

Iñaki Baz Castillo

El Domingo 05 Abril 2009, Ken Bloom escribi=C3=B3:
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=20
package (so irb was a link to irb1.8).
When compiling and installing Ruby1.9.1 from sources, it created /usr/bin/r=
uby=20
and /usr/bin/irb.
But it's strange since /usr/bin/irb was a softlink and after Ruby 1.9.1=20
install it remains being a softlink to irb1.8, but irb1.8 is now a copy of =
the=20
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 i=
n=20
those distributions. Installing Ruby 1.9.1 from experimental in my Debian E=
tch=20
would require upgrading my system to sid/experimental and I cannot do it.

Thanks a lot for your help.


=2D-=20
I=C3=B1aki Baz Castillo <[email protected]>
 
R

Rick DeNatale

El Domingo 05 Abril 2009, Ken Bloom escribi=F3:

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 o= f
the
installed irb (Ruby 1.9.1).


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

When you are installing source on a Debian based system (which would includ=
e
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=3D/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.
 
R

Rick DeNatale

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 inste= ad
of just
./configure
make
sudo make install

you need to do something like

./configure --prefix=3D/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.

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

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

--=20
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

Iñaki Baz Castillo

El Domingo 05 Abril 2009, Rick DeNatale escribi=C3=B3:
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 crea=
te=20
ruby1.9 and irb1.9 by default, so I didn0t care about using /usr/bin=20
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.


=2D-=20
I=C3=B1aki Baz Castillo <[email protected]>
 
I

Iñaki Baz Castillo

El Domingo 05 Abril 2009, Rick DeNatale escribi=C3=B3:
An afterthought, that configure command should probably be
./configure --prefix=3D/usr/local/ruby1.9 --program-suffix=3D1.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.

=2D-=20
I=C3=B1aki Baz Castillo <[email protected]>
 
I

Igor Pirnovar

Iñaki Baz Castillo said:
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
 
I

Iñaki Baz Castillo

El Domingo 05 Abril 2009, Igor Pirnovar escribi=C3=B3:
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.

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

./configure --prefix=3D/usr/local/ --program-suffix=3D1.9

Then I get:

/usr/local/bin# ll
=2Drwxr-xr-x 1 root root 4,4K 2009-04-05 16:49 erb1.9*
=2Drwxr-xr-x 1 root root 791 2009-04-05 16:49 gem1.9*
=2Drwxr-xr-x 1 root root 323 2009-04-05 16:49 irb1.9*
=2Drwxr-xr-x 1 root root 1,3K 2009-04-05 16:49 rake1.9*
=2Drwxr-xr-x 1 root root 415 2009-04-05 16:49 rdoc1.9*
=2Drwxr-xr-x 1 root root 78 2009-04-05 16:49 ri1.9*
=2Drwxr-xr-x 1 root root 5,4M 2009-04-05 16:48 ruby1.9*
=2Drwxr-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.


=2D-=20
I=C3=B1aki Baz Castillo <[email protected]>
 
K

Ken Bloom

El Domingo 05 Abril 2009, Ken Bloom 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. 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
 
I

Iñaki Baz Castillo

El Domingo 05 Abril 2009, Ken Bloom escribi=C3=B3:
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=
=20
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 ;)

Thanks.


=2D-=20
I=C3=B1aki Baz Castillo <[email protected]>
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top