如何在没有RVM的情况下在Ubuntu上安装Ruby 2
我想安装ruby 2.0使用
sudo apt-get install ruby2.0
但是ruby2.0没有可用的包
我想用apt-get install来安装它,就像ruby 1.9.1一样
有什么build议么?
sudo apt-get -y更新 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 光盘ruby-2.0.0-p451 / ./configure --prefix = / usr / local 使 sudo make install
从这里如何在Ubuntu 12.04上正确安装ruby 2.0.0?
UPDATE
对于ruby2.1.5
sudo apt-get -y更新 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 使 sudo make install
如果你仍然看到一个老的ruby检查你的符号链接ls -la /usr/bin/ruby
hector
sudo apt-add-repository ppa:brightbox/ruby-ng-experimental && sudo apt-get update && sudo apt-get install -y ruby2.0 ruby2.0-dev ruby2.0-doc
易于使用^ㅡ^
# Adds Ruby 2.2 to Ubuntu 14.04 sudo apt-add-repository ppa:brightbox/ruby-ng # Adds Ruby v1.9/2.0/2.1/2.2 to Ubuntu 14.04/15.04 # sudo add-apt-repository ppa:brightbox/ruby-ng-experimental sudo apt-get update sudo apt-get install ruby2.2 ruby2.2-dev # http://stackoverflow.com/a/1892889/2126990 # priority ruby: https://gist.github.com/brodock/7693207 sudo update-alternatives --remove ruby /usr/bin/ruby2.2 sudo update-alternatives --remove irb /usr/bin/irb2.2 sudo update-alternatives --remove gem /usr/bin/gem2.2 sudo update-alternatives \ --install /usr/bin/ruby ruby /usr/bin/ruby2.2 50 \ --slave /usr/bin/irb irb /usr/bin/irb2.2 \ --slave /usr/bin/rake rake /usr/bin/rake2.2 \ --slave /usr/bin/gem gem /usr/bin/gem2.2 \ --slave /usr/bin/rdoc rdoc /usr/bin/rdoc2.2 \ --slave /usr/bin/testrb testrb /usr/bin/testrb2.2 \ --slave /usr/bin/erb erb /usr/bin/erb2.2 \ --slave /usr/bin/ri ri /usr/bin/ri2.2 update-alternatives --config ruby update-alternatives --display ruby $ irb irb(main):001:0> RUBY_VERSION => "2.2.0" $ ruby --version ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux-gnu]
自从这个问题得到解答,我发现了一个新的select:
https://www.brightbox.com/docs/ruby/ubuntu/
简而言之:
# For ubuntu >= 14.04 install software-properties-common # instead of python-software-properties sudo apt-get install python-software-properties sudo apt-add-repository ppa:brightbox/ruby-ng sudo apt-get update sudo apt-get -y install ruby2.2 ruby-switch sudo ruby-switch --set ruby2.2
我必须说,根据我的testing,这比这里显示的替代方法更快,因为编译步骤被跳过了。
在没有RVM的情况下在ubuntu上安装ruby的更好的方法是在terminal安装rbenv ,如下所示:
$ sudo apt-get update
使用apt-get安装rbenv和Ruby依赖关系:
$ 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
现在运行这些命令如下:
$ 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
时间安装ruby:
$ rbenv install 2.3.3
这是最新和稳定的版本
$ rbenv global 2.3.3
检查版本
$ ruby -v
要禁用本地文档,因为此过程可能很漫长:
$ echo "gem: --no-document" > ~/.gemrc
安装捆绑软件gem来pipe理你的应用程序依赖关系:
$ gem install bundler
我特别喜欢ruby-install,可以在这里find: https : //github.com/postmodern/ruby-install
它会安装ruby(任何版本),JRuby等,并且还有许多其他function。