如何在 Ubuntu 14.04 上安装 Ruby 2.1.4
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26595620/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install Ruby 2.1.4 on Ubuntu 14.04
提问by Alek
I dont know how to install the latest Ruby on Ubuntu.
我不知道如何在 Ubuntu 上安装最新的 Ruby。
First I installed the default Ruby 1.9.3, using
首先我安装了默认的 Ruby 1.9.3,使用
sudo apt-get install ruby
Then I tried to install the 2.0 version using
然后我尝试使用安装 2.0 版本
sudo apt-get install ruby2.0
My version of Ruby is still "ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux])"
我的Ruby版本还是“ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux])”
What should I do?
我该怎么办?
回答by Vlad Frolov
There is a PPA with up-to-date versions of Ruby 2.x for Ubuntu 12.04+:
有一个用于 Ubuntu 12.04+ 的带有最新版本的 Ruby 2.x 的 PPA:
$ sudo apt-add-repository ppa:brightbox/ruby-ng
$ sudo apt-get update
$ sudo apt-get install ruby2.4
$ ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux-gnu]
回答by dubadub
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:
然后安装rbenv,用于安装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:
然后(可选)告诉 Rubygems 不要安装本地文档:
echo "gem: --no-ri --no-rdoc" > ~/.gemrc
Credits: https://gorails.com/setup/ubuntu/14.10
积分:https: //gorails.com/setup/ubuntu/14.10
Warning!!!There are issues with Gnome-Shell. See comment below.
警告!!!有问题Gnome-Shell。请参阅下面的评论。
回答by user3301099
Best is to install it using rvm(ruby version manager).
Run following commands in a terminal:
最好是使用rvm(ruby 版本管理器)安装它。
在终端中运行以下命令:
sudo apt-get update
sudo apt-get install build-essential make curl
\curl -L https://get.rvm.io | bash -s stable
source ~/.bash_profile
rvm install ruby-2.1.4
Then check ruby versions installed and in use:
然后检查安装和使用的 ruby 版本:
rvm list
rvm use --default ruby-2.1.4
Also you can directly add ruby bin path to PATH variable. Ruby is installed in
您也可以直接将 ruby bin 路径添加到 PATH 变量。Ruby 安装在
$HOME/.rvm/rubies export PATH=$PATH:$HOME/.rvm/rubies/ruby-2.1.4/bin
回答by Bartosz ??cki
Use RVM(Ruby Version Manager) to install and manage any versions of Ruby. You can have multiple versions of Ruby installed on the machine and you can easily select the one you want.
使用RVM(Ruby 版本管理器)来安装和管理任何版本的 Ruby。您可以在机器上安装多个版本的 Ruby,并且您可以轻松地选择您想要的版本。
To install RVM type into terminal:
要将 RVM 类型安装到终端中:
\curl -sSL https://get.rvm.io | bash -s stable
And let it work. After that you will have RVM along with Ruby installed.
让它发挥作用。之后,您将安装 RVM 和 Ruby。
Source: RVM Site
来源:RVM 网站
回答by Sudhir Vishwakarma
update ubuntu:
更新 Ubuntu:
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 rvm, which manages the ruby versions:
安装 rvm,它管理 ruby 版本:
to install rvm use the following command.
要安装 rvm,请使用以下命令。
\curl -sSL https://get.rvm.io | bash -s stable
source ~/.bash_profile
rvm install ruby-2.1.4
Check ruby versions installed and in use:
检查已安装和正在使用的 ruby 版本:
rvm list
rvm use --default ruby-2.1.4

