ubuntu安裝ruby的幾種方法總結

一、apt-get安裝html

能夠使用apt-cache查詢功能,找到對應的可用的ruby版本。linux

$ sudo apt-cache search ruby #這個結果很長,我只截取最後與ruby有關的部分 ruby1.8 - Interpreter of object-oriented scripting language Ruby 1.8 ruby1.8-dev - Header files for compiling extension modules for the Ruby 1.8 ruby1.8-examples - Examples for Ruby 1.8 rubygems - package management framework for Ruby libraries/applications rubygems1.8 - Transitional package for rubygems rubygems-doc - Transitional package for rubygems ruby1.9.1-full - Ruby 1.9.1 full installation ruby1.8-full - Ruby 1.8 full installation ruby-switch - switch between different Ruby interpreters ruby2.1 - Interpreter of object-oriented scripting language Ruby libruby2.1 - Libraries necessary to run Ruby 2.1 ruby2.1-dev - Header files for compiling extension modules for the Ruby 2.1 ruby2.1-tcltk - Ruby/Tk for Ruby 2.1 ruby2.1-doc - Documentation for Ruby 2.1 ruby2.2 - Interpreter of object-oriented scripting language Ruby libruby2.2 - Libraries necessary to run Ruby 2.2 ruby2.2-dev - Header files for compiling extension modules for the Ruby 2.2 ruby2.2-tcltk - Ruby/Tk for Ruby 2.2 ruby2.2-doc - Documentation for Ruby 2.2 ruby2.3 - Interpreter of object-oriented scripting language Ruby ruby2.3-doc - Documentation for Ruby 2.3 libruby2.3 - Libraries necessary to run Ruby 2.3 ruby2.3-dev - Header files for compiling extension modules for the Ruby 2.3 ruby2.3-tcltk - Ruby/Tk for Ruby 2.3 libruby2.4 - Libraries necessary to run Ruby 2.4 ruby2.4-dev - Header files for compiling extension modules for the Ruby 2.4 ruby2.4 - Interpreter of object-oriented scripting language Ruby ruby2.4-doc - Documentation for Ruby 2.4

能夠看到官方目前支持較多版本,git

安裝樣例github

sudo apt-get install ruby #自動安裝最新版本
sudo apt-get install ruby2.0

沒法指定子版本,只能用repo已有的版本。ubuntu

 

二、使用brightbox ppa倉庫安裝ruby

這是一個repo方案,已經更新到2.4版本,參考:https://www.brightbox.com/docs/ruby/ubuntu/bash

If you’re using Ubuntu 14.04 (Trusty) or newer then you can add the package repository like thisapp

$ sudo apt-get install software-properties-common $ sudo apt-add-repository ppa:brightbox/ruby-ng $ sudo apt-get update
$ sudo apt-get install ruby1.9.3 ruby1.9.3-dev

沒法指定子版本,只能用repo已有的版本。curl

 

三、利用rvm安裝ide

$ curl -L get.rvm.io | bash -s stable $ source ~/.bashrc $ source ~/.bash_profile $ source ~/.profile $ rvm -v $ rvm list known $ rvm install 2.2 $ ruby -v ruby 2.2.6p396 (2016-11-15 revision 56800) [x86_64-linux] 若是想在Ubuntu上安裝多個Ruby版本,那麼能夠使用下面的命令來指定使用rvm做爲默認的Ruby版本管理。 rvm use ruby 1.9.3 --default
rvm use ruby 1.9.3-p551 --default #制定子版本

能夠指定子版本,好比 rvm install 1.9.3-p551

附rvm list known結果參考。

$ rvm list known Warning, new version of rvm available '1.29.2', you are using older version '1.29.1'. You can disable this warning with: echo rvm_autoupdate_flag=0 >> ~/.rvmrc You can enable auto-update  with:    echo rvm_autoupdate_flag=2 >> ~/.rvmrc # MRI Rubies [ruby-]1.8.6[-p420] [ruby-]1.8.7[-head] # security released on head [ruby-]1.9.1[-p431] [ruby-]1.9.2[-p330] [ruby-]1.9.3[-p551] [ruby-]2.0.0[-p648] [ruby-]2.1[.10] [ruby-]2.2[.6] [ruby-]2.3[.3] [ruby-]2.4[.0] ruby-head # for forks use: rvm install ruby-head-<name> --url https://github.com/github/ruby.git --branch 2.2
 # JRuby jruby-1.6[.8] jruby-1.7[.26] jruby[-9.1.7.0] jruby-head # Rubinius rbx-1[.4.3] rbx-2.3[.0] rbx-2.4[.1] rbx-2[.5.8] rbx[-3.71] rbx-head # Opal opal # Minimalistic ruby implementation - ISO 30170:2012 mruby-1.0.0 mruby-1.1.0 mruby-1[.2.0] mruby[-head] # Ruby Enterprise Edition ree-1.8.6 ree[-1.8.7][-2012.02] # Topaz topaz # MagLev maglev[-head] maglev-1.0.0 # Mac OS X Snow Leopard Or Newer macruby-0.10 macruby-0.11 macruby[-0.12] macruby-nightly macruby-head # IronRuby ironruby[-1.1.3] ironruby-head
結果參考

 

四、編譯安裝

參考前一筆記:ubuntu編譯安裝ruby1.9.3,從p551降級到p484

 

Best Wishes!Any question pls fell free to contact me!

相關文章
相關標籤/搜索