How to install ruby 1.9.2 on Ubuntu 10.04
The current LTS version of Ubuntu is 10.04 and the most current version of ruby it ships with is 1.9.1. Unfurtunately 1.9.1 wasn’t that great of a release and anyone using the 1.9 branch really should use the stable 1.9.2.
After doing a bit of researching I found some information on how the best approach to get ruby installed is. Downloading the source, compiling it and registering the installed version with the package manager.
The following little bash script takes care of installing ruby 1.9.2 on a ubuntu or debian based system (or any other version if you change the $Version variable in the script). The script just consolidates information found online and wraps it up into a nice bashscript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#!/bin/bash
#===============================================================================
#
# FILE: install_ruby_1.9.sh
#
# USAGE: ./install_ruby_1.9.sh
#
# AUTHOR: Ryan Schulze (rs), ryan@dopefish.de
# CREATED: 07/07/2011 11:59:37 AM CDT
#===============================================================================
Version="1.9.2-p180"
GZFile="ruby-${Version}.tar.gz"
Download="http://ftp.ruby-lang.org/pub/ruby/1.9/${GZFile}"
if [[ "$(id -u)" != "0" ]]
then
echo "You need root permission to execute this script"
exit
fi
apt-get -q update
apt-get -qy upgrade
apt-get install -qy build-essential wget zlib1g-dev libssl-dev libffi-dev autoconf
cd /usr/local/src/
test -e ${GZFile} || wget ${Download}
tar -xzf ${GZFile}
cd ruby-${Version}
autoconf
./configure --with-ruby-version=${Version} --prefix=/usr --program-suffix=${Version}
make
make install
mkdir -p /usr/lib/ruby/gems/${Version}/bin
update-alternatives \
--install /usr/bin/ruby ruby /usr/bin/ruby${Version} $(echo ${Version//./}|cut -d- -f1) \
--slave /usr/share/man/man1/ruby.1.gz ruby.1.gz /usr/share/man/man1/ruby${Version}.1 \
--slave /usr/lib/ruby/gems/bin gem-bin /usr/lib/ruby/gems/${Version}/bin \
--slave /usr/bin/erb erb /usr/bin/erb${Version} \
--slave /usr/bin/irb irb /usr/bin/irb${Version} \
--slave /usr/bin/rdoc rdoc /usr/bin/rdoc${Version} \
--slave /usr/bin/ri ri /usr/bin/ri${Version} \
--slave /usr/bin/gem gem /usr/bin/gem${Version} \
update-alternatives --config ruby
update-alternatives --display gem >/dev/null 2>&1 && update-alternatives --remove-all gem
echo "[+] Done installing"
ruby -v
|