I currently have ruby version 1.8.2 in my machine and I would like to upgrade it to 1.9.2. How am i supposed to do it?
Installing Ruby from Ubuntu Repositories The easiest way to install Ruby on Ubuntu is by using the apt package manager. At the time of writing, the version in the Ubuntu repositories is 2.7. 0 , which may not always be the latest stable release. Your Ruby version may differ from the one shown above.
I use Ubuntu, and I've found the easiest way to install newer versions of Ruby is to use rvm.
The instructions are here: https://rvm.io/rvm/install/
Basically, it installs different versions of Ruby locally for the user and updates environment variables for Ruby and gems based on which version you decide to use.
It's this easy:
jim@schubert:~$ rvm use system
Now using system ruby.
jim@schubert:~$ ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]
jim@schubert:~$ gem -v
1.3.7
jim@schubert:~$ rvm use 1.9.2
Using /home/jim/.rvm/gems/ruby-1.9.2-p180
jim@schubert:~$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
jim@schubert:~$ gem -v
1.5.2
jim@schubert:~$
I don't like having RVM on production server, so I usually install ruby from source with an install script like this:
#!/bin/bash
tmp_dir="/tmp"
version="2.2.3"
minor_version="2.2"
ruby_version="ruby-$version"
echo "*******************"
echo "* Installing Ruby *"
echo "*******************"
sudo apt-get install -y autoconf build-essential libreadline-dev libssl-dev libyaml-dev zlib1g-dev libffi-dev
mkdir -p "$tmp_dir"
cd "$tmp_dir"
wget "http://cache.ruby-lang.org/pub/ruby/$minor_version/$ruby_version.tar.gz"
tar -xvzf $ruby_version.tar.gz
cd $ruby_version
./configure --disable-install-doc
make --jobs `nproc`
sudo make install
cd ..
rm $ruby_version.tar.gz
rm -rf $ruby_version
echo "*******************"
echo "* Ruby installed! *"
echo "*******************"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With