79

I have successfully installed rvm, but when I run the following commands

sudo apt-get update

Or:

rvm install 2.0.0

I have the following errors:

W: Failed to fetch http://ppa.launchpad.net/cheleb/blender-svn/ubuntu/dists/precise/main/source/Sources  404  Not Found

W: Failed to fetch http://ppa.launchpad.net/cheleb/blender-svn/ubuntu/dists/precise/main/binary-amd64/Packages  404  Not Found

W: Failed to fetch http://ppa.launchpad.net/cheleb/blender-svn/ubuntu/dists/precise/main/binary-i386/Packages  404  Not Found

W: Failed to fetch http://ppa.launchpad.net/ferramroberto/oneiric/ubuntu/dists/precise/main/source/Sources  404  Not Found

W: Failed to fetch http://ppa.launchpad.net/ferramroberto/oneiric/ubuntu/dists/precise/main/binary-amd64/Packages  404  Not Found

W: Failed to fetch http://ppa.launchpad.net/ferramroberto/oneiric/ubuntu/dists/precise/main/binary-i386/Packages  404  Not Found

How can I fix these errors?

Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
Kashiftufail
  • 10,815
  • 11
  • 45
  • 79

8 Answers8

192

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
UltraInstinct
  • 43,308
  • 12
  • 81
  • 104
Pravin Mishra
  • 8,298
  • 4
  • 36
  • 49
56

Use rvm to install stable ruby:

curl -sSL https://get.rvm.io | bash -s stable --ruby

or, if you have rvm already, get stable version:

rvm get stable

Install ruby and use the specific version of ruby (remember to use login shell)

/bin/bash --login
rvm install 2.0.0
rvm use 2.0.0
rvm rubygems latest
ruby --version

As found on the official RVM website.

EDIT: As @prem points out run this at first and follow the above steps if there is a public key error

gpg --keyserver hkp://keys.gnupg.net --recv-keys \ 409B6B1796C275462A1703113804BB82D39DC0E3

Use rbenv to install ruby:

Install necessary dependancies:

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

Install rbenv:

cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile

Install ruby:

rbenv install -v 2.0.0
gmuraleekrishna
  • 3,375
  • 1
  • 27
  • 45
  • some I followed steps and it was continuously falling then I run rvm get and run these steps again and it worked – Guru Mar 25 '15 at 09:52
  • @Guru edited answer to upgrade rvm to stable version – gmuraleekrishna Mar 27 '15 at 07:27
  • 4
    If u stumble on public **key issues** run this `gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3` and follow the above steps. – iamprem May 25 '15 at 21:10
  • I finished the download and it worked fine. After the restart of my computer, an infamous message 'RVM is not a function' was shown when typing command `ruby` and `rvm use 2.0.0`. Here's the solution : [rvm installation not working: “RVM is not a function”](http://stackoverflow.com/questions/9336596/rvm-installation-not-working-rvm-is-not-a-function) – Mincong Huang Mar 20 '16 at 09:57
32

From the travis-cli installation instructions for Ubuntu, the Brightbox Ruby NG(NextGeneration) ppa:

$ sudo apt-get install python-software-properties
$ sudo apt-add-repository ppa:brightbox/ruby-ng
$ sudo apt-get update
$ sudo apt-get install ruby2.1 ruby-switch
$ sudo ruby-switch --set ruby2.1
ThorSummoner
  • 16,657
  • 15
  • 135
  • 147
  • 2
    This worked for my Ubuntu 14, I would add also `$ sudo apt-get install ruby2.1-dev` that you will need for example if you want to install [Jekyll](http://jekyllrb.com/) which depends on RedCloth, that will complain when installing if headers (like ruby.h) are missing. – Gianluca Casati Sep 26 '15 at 19:24
  • 1
    Need to update the first line: `sudo apt-get install software-properties-common` – Matt Darby Oct 21 '15 at 17:12
  • 3
    Works on my machine :) On ubuntu trusty, vagrant. In case of 2.2dev you need: `apt-get install ruby2.2 ruby2.2-dev ruby-switch` and `ruby-switch --set ruby2.2`. – ColCh Jan 08 '16 at 14:32
  • after install, i try install jekyll, but get this error `mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h` – ghanbari Aug 23 '16 at 19:52
  • @ghanbari you may need the header files, they aren't packaged with the release (as only machines that compile software need them), try installing `ruby2.1-dev` if it exists, you are looking for a package named after the primary package with a `-dev` suffix. – ThorSummoner Aug 23 '16 at 20:55
7

Although this answer was accepted, I would strongly recommend using rvm rather. I had nothing but trouble trying to install ruby without it. See e.g. this guide:

https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm

D2TheC
  • 2,203
  • 20
  • 23
3

Any easy way to install ruby is with ruby-install. I had compile errors when building ruby from scratch, but ruby-install encountered no such problems.

edit: I've had problems with rvm in the past, and feel I should actively recommend against this. That's just me personally, though. I've had okay luck with rbenv, but always use it in conjunction with ruby-install.

duma
  • 455
  • 1
  • 5
  • 10
2

You have some ppa sources enabled that aren't available for your version of Ubuntu. Comment those out in your /etc/apt/sources.list , run sudo apt-get update , and you'll be fine.

automan
  • 47
  • 4
1

Use rbenv

The first step is to install some dependencies for Ruby.

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

Installing with rbenv is a simple two step process. First you install rbenv, and then ruby-build:

cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

rbenv install 2.0.0
rbenv global 2.0.0
ruby -v

The original post on gorails.com

borracciaBlu
  • 4,017
  • 3
  • 33
  • 41
1

I put @PravinMishra's source into a Gist and now you can simply use this one liner:

wget -O - https://git.io/vvkI4 | bash

NOTE: Don't trust my Gist blindly, download the file and look into it before you run it!

rubo77
  • 19,527
  • 31
  • 134
  • 226