Ubuntu / Debian: using update-alternatives to manage multiple ruby interpreters

2,326 views
Skip to first unread message

David Lee

unread,
Feb 7, 2008, 12:39:51 AM2/7/08
to rails-...@googlegroups.com
If any of you are using Ubuntu this is a pretty nice way to manage multiple ruby interpreters.

It has the advantage of managing the manpages, ri, and irb as "slaves", so they change when a new interpreter is selected.

here's the code:

# become root
su

# make sure the packages are installed for 1.8 & 1.9
aptitude install -s  ~n^ruby1.[89]$ ~n^irb1.[89]$ ~n^ri1.[89]

# install ruby1.8 & friends with priority 500
# so this will be the default "auto" choice
update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.8 500 \
                    --slave   /usr/share/man/man1/ruby.1.gz ruby.1.gz \
                                  /usr/share/man/man1/ruby.1.8.gz \
                    --slave   /usr/bin/ri ri /usr/bin/ri1.8 \
                    --slave   /usr/bin/irb irb /usr/bin/irb1.8

# install ruby1.9 & friends with priority 400
update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9 400 \
                    --slave   /usr/share/man/man1/ruby.1.gz ruby.1.gz \
                                   /usr/share/man/man1/ruby.1.9.gz \
                    --slave   /usr/bin/ri ri /usr/bin/ri1.9 \
                    --slave   /usr/bin/irb irb /usr/bin/irb1.9

# choose your interpreter
# changes symlinks for /usr/bin/ruby ,
# /usr/bin/irb, /usr/bin/ri and man (1) ruby
update-alternatives --config ruby

for those with additional interpreters in say /usr/local/bin, other Debian variants, or managing other tools, vary as required.

% man update-alternatives

hope wrapping didn't mangle it too much, and that someone finds this useful ...
--
cheers,
David Lee

Anthony Richardson

unread,
Feb 7, 2008, 1:55:29 AM2/7/08
to rails-...@googlegroups.com
Hi David,

That is handy. I have been using update-alternatives for my java
installs and never thought to use it for Ruby. great idea.

Cheers,

Anthony Richardson

Adam Salter

unread,
Feb 7, 2008, 5:48:52 PM2/7/08
to rails-...@googlegroups.com
David,
You should blog this so that the internets can know.

Cheers,
-Adam

Lachlan Hardy

unread,
Feb 7, 2008, 5:56:30 PM2/7/08
to rails-...@googlegroups.com
> You should blog this so that the internets can know.

+1

David Lee

unread,
Feb 7, 2008, 10:01:16 PM2/7/08
to rails-...@googlegroups.com
good idea - maybe i can make blogsies on the weekend.
I've been meaning to put one up on rubyist.net.au for yonks now ..

cheers

Xavier Shay

unread,
Feb 7, 2008, 10:08:14 PM2/7/08
to rails-...@googlegroups.com
yes blog

You should use http://enkiblog.com/
In my totally not biased at all opinion.

Xav

Lachlan Hardy

unread,
Feb 7, 2008, 10:20:44 PM2/7/08
to rails-...@googlegroups.com

> You should use http://enkiblog.com/
> In my totally not biased at all opinion.

+1

I'm switching as soon as the second comment bug is fixed. (and I've
gotten married, got back from my honeymoon, resumed my job, found
spare time for personal dev, written a migration from SimpleLog,
hacked together a shiny new design and found some new hosting)

Should be any day now...

David Lee

unread,
Feb 7, 2008, 10:50:16 PM2/7/08
to rails-...@googlegroups.com
i dig it:Hacking code is the easiest way to customize something

sums up everything that pisses me off about the rails blogging apps ive used.

i'll take a look
--
cheers,
David Lee

Sutto

unread,
Feb 8, 2008, 7:30:07 AM2/8/08
to Ruby on Rails Oceania
I can't believe I missed Enki, thanks for the link - I recently
rewrote my own blog platform (at http://blog.ninjahideout.com) because
I didn't like SimpleLog and couldn't find any other real alternatives.

On Feb 8, 12:08 pm, Xavier Shay <xavier-l...@rhnh.net> wrote:
> yes blog
>
> You should usehttp://enkiblog.com/
> In my totally not biased at all opinion.
>
> Xav
>
> On 08/02/2008, at 2:01 PM, David Lee wrote:
>
> > good idea - maybe i can make blogsies on the weekend.
> > I've been meaning to put one up on rubyist.net.au for yonks now ..
>
> > cheers
>
Reply all
Reply to author
Forward
0 new messages