How to install Ruby 2 on Ubuntu without RVM
sudo apt-get -y update
sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p451.tar.gz
tar -xvzf ruby-2.0.0-p451.tar.gz
cd ruby-2.0.0-p451/
./configure --prefix=/usr/local
make
sudo make install
from here How do I install ruby 2.0.0 correctly on Ubuntu 12.04?
UPDATE
for ruby 2.1.5
sudo apt-get -y update
sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget http://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.5.tar.gz
tar -xvzf ruby-2.1.5.tar.gz
cd ruby-2.1.5/
./configure --prefix=/usr/local
make
sudo make install
if you are still seeing an older ruby check your symlink ls -la /usr/bin/ruby
from hector
How do I install ruby 2.0.0 correctly on Ubuntu 12.04?
follow below steps
sudo apt-get -y update
sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p481.tar.gz
tar -xvzf ruby-2.0.0-p481.tar.gz
cd ruby-2.0.0-p481/
./configure --prefix=/usr/local
make
sudo make install
How do I install Ruby 1.9.3 on Ubuntu without RVM?
1st approach
Source
http://lenni.info/blog/2012/05/installing-ruby-1-9-3-on-ubuntu-12-04-precise-pengolin/
The new Ubuntu release has just rolled around and with it a slew of new packages. Personally, I'm tracking the development of Ruby quite closely but the default Ruby on Ubuntu ist still the 1.8 series which I can't recommend. Ruby 1.9 has some performance improvements and 1.9.3 in particular a lot of them compared to 1.9.2.
However, as I have elaborated in a previous post getting the Ruby 1.9 series on Ubuntu without using RVM instead of 1.8 isn't all that easy. Please read the post if you are interested in the details.
The short version is: You can get Ruby 1.9.3-p0 by installing the ruby-1.9.1 package. (The package is called 1.9.1 because that is the ABI version.)
If you want to make Ruby 1.9 the default do the following:
sudo apt-get update
sudo apt-get install ruby1.9.1 ruby1.9.1-dev \
rubygems1.9.1 irb1.9.1 ri1.9.1 rdoc1.9.1 \ build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev
sudo update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.1 400 \
--slave /usr/share/man/man1/ruby.1.gz ruby.1.gz \
/usr/share/man/man1/ruby1.9.1.1.gz \
--slave /usr/bin/ri ri /usr/bin/ri1.9.1 \
--slave /usr/bin/irb irb /usr/bin/irb1.9.1 \
--slave /usr/bin/rdoc rdoc /usr/bin/rdoc1.9.1
# choose your interpreter
# changes symlinks for /usr/bin/ruby , /usr/bin/gem
# /usr/bin/irb, /usr/bin/ri and man (1) ruby
sudo update-alternatives --config ruby
sudo update-alternatives --config gem
# now try
ruby --version
If you want to make this your exclusive Ruby and get rid of Ruby 1.8 follow the uninstallation instructions.
Edit: I found out today that there also is a package called ruby1.9.3 however that is just a proxy package that doesn't have any files itself and only depends on ruby1.9.1. Aptitude confirms this:
Ruby uses two parallel versioning schemes: the `Ruby library compatibility version' (1.9.1 for this package), which is similar to a library SONAME, and the 'Ruby version' (1.9.3 for this package). Ruby packages in Debian are named using the Ruby library compatibility version, which is sometimes confusing for users who do not follow Ruby development closely. This package depends on the ruby1.9.1 package, and provides compatibility symbolic links from 1.9.3 executables and manual pages to their 1.9.1 counterparts.
There doesn't seem to be a rubygems1.9.3.
2nd approach
Also This link i found useful its very simple and effective.
http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/
How to install Ruby 2.1.4 on Ubuntu 14.04
First of all, install the prerequisite libraries:
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
Then install rbenv, which is used to install Ruby:
cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
rbenv install 2.3.1
rbenv global 2.3.1
ruby -v
Then (optional) tell Rubygems to not install local documentation:
echo "gem: --no-ri --no-rdoc" > ~/.gemrc
Credits: https://gorails.com/setup/ubuntu/14.10
Warning!!!
There are issues with Gnome-Shell
. See comment below.
upgrade ruby version without rvm
This is just an example of how to resolve this issue. The paths and file names might be different on your system, but you should get the idea from here:
# First locate the original ruby
> which ruby
/usr/bin/ruby # <- Your path might be different
# Then locate ruby19
> which ruby19
/usr/bin/ruby19
# Move the old ruby out of the way
> mv /usr/bin/ruby /usr/bin/ruby_old
# Link ruby to the new ruby (ruby19)
# ln -s is used to create a new symbolic link. See "man ln" for more info.
> cd /usr/bin
> ln -s ruby19 ruby
Now you should have:
/usr/bin/ruby_old # The old executable
/usr/bin/ruby -> /usr/bin/ruby19 # The new link
/usr/bin/ruby19 # The new executable
Note: it's easy to break your system ruby if you're not careful using this method. That's why RVM is usually a better solution if you have the choice. You can leave a comment if something breaks, and I will try and improve the instructions.
installed ruby using apt-get install ruby 2.0.0 succeeded but not using correct ruby version
If you're new to linux I'd recommend using something like RVM (Ruby Version Manager) to install ruby. It makes it easier to switch ruby versions and manage multiple gemsets.
To install RVM with the latest (stable) ruby:
\curl -L https://get.rvm.io | bash -s stable --ruby
then check which rubies are installed by using
rvm list
you can then switch ruby versions using
rvm use 2.0.0 --default
with the --default
flag overriding any system ruby.
Update
If you really don't want to use RVM, then use
sudo apt-get install checkinstall
wget -c http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz
tar -xzf ruby-2.0.0-p0.tar.gz
cd ruby-2.0.0-p0
./configure
make
sudo checkinstall -y \
--pkgversion 2.0.0-p0 \
--provides "ruby-interpreter"
checkinstall
will package the source, making it easier to remove in the future
You'll then need to add the Ruby binaries to your path, by editing the env file:
sudo nano /etc/environment
add /usr/local/ruby/bin
PATH="/usr/local/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
then run
source /etc/environment
to reload the file, and check your ruby version with
ruby -v
Related Topics
How to Check a Word Is Already All Uppercase
Ruby: Accessing Rake Task from a Gem Without Rails
Always Getting 401 Unauthorized with New Install of Rails + Devise
What Is an Illegal Octal Digit
Generate a Powerset of a Set Without Keeping a Stack in Erlang or Ruby
Differencebetween <%= ... %> and <% ... %> in Ruby on Rails
Convert Time to Other Timezone
Store the Day of the Week and Time
Supporting Ruby 1.9's Hash Syntax in Ruby 1.8
How to Install JSON Gem - Failed to Build Gem Native Extension(MAC 10.10)
Is There a Natural_Sort_By Method for Ruby
"Stack Level Too Deep" Running Rake Db:Create:All
Validate Words Against an English Dictionary in Rails
How to Download via Http Only Piece of Big File with Ruby
Activerecord::Adapternotspecified Database Configuration Does Not Specify Adapter