我已经成功安装了rvm
,但是当我运行以下命令时
sudo apt-get update
要么:
rvm install 2.0.0
我有以下错误:
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
我该如何解决这些错误?
按照以下步骤
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
rvm
to install stable ruby:curl -sSL https://get.rvm.io | bash -s stable --ruby
或者,如果你已经有rvm,获得稳定版本:
rvm get stable
安装ruby并使用特定版本的ruby(记得使用login shell)
/bin/bash --login
rvm install 2.0.0
rvm use 2.0.0
rvm rubygems latest
ruby --version
如在the official RVM website上找到的。
编辑:正如@prem指出的那样,首先运行此命令,如果存在公钥错误,请按照上述步骤操作
gpg --keyserver hkp://keys.gnupg.net --recv-keys \ 409B6B1796C275462A1703113804BB82D39DC0E3
rbenv
to install 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 libffi-dev
安装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
安装红宝石:
rbenv install -v 2.0.0
从travis-cli installation instructions for Ubuntu,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
虽然这个答案被接受了,但我强烈建议使用rvm。我没有遇到麻烦在没有它的情况下安装ruby。参见例如本指南:
安装ruby的任何简单方法都是使用ruby-install。从头开始构建ruby时我遇到了编译错误,但ruby-install
没遇到这样的问题。
编辑:我过去曾遇到rvm
的问题,觉得我应该积极推荐这个。不过,那只是我个人而已。我和rbenv
运气好,但总是和ruby-install
一起使用它。
您启用了一些不适用于您的Ubuntu版本的ppa源。在你的/etc/apt/sources.list中评论那些,运行sudo apt-get update,你会没事的。
使用rbenv
第一步是为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
使用rbenv进行安装是一个简单的两步过程。首先安装rbenv,然后安装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
我把@ PravinMishra的来源放到Gist中,现在你可以简单地使用这个内衬:
wget -O - https://git.io/vvkI4 | bash
注意:不要盲目信任我的Gist,下载文件并在运行之前查看它!