1. 程式人生 > >在ubuntu中安裝及使用rvm管理ruby版本

在ubuntu中安裝及使用rvm管理ruby版本


RVM的主要作用是方便的管理系統中的多個ruby版本而不至於混亂。

我們來看看如何安裝RVM,我使用的ubuntu12.04LTS。

準備工作

後面需要使用curl,用dpkg -s curl命令檢查一下系統中有沒有安裝

[email protected]:~$ dpkg -s curl
Package: curl
Status: install ok installed
Priority: optional
Section: web
Installed-Size: 338
Maintainer: Ubuntu Developers <[email protected]
> Architecture: i386 Version: 7.22.0-3ubuntu4 Replaces: curl-ssl Provides: curl-ssl Depends: libc6 (>= 2.7), libcurl3 (>= 7.16.2-1), zlib1g (>= 1:1.1.4) Description: Get a file from an HTTP, HTTPS or FTP server curl is a client to get files from servers using any of the supported protocols. The command is designed to work without user interaction or any kind of interactivity. . curl offers a busload of useful tricks like proxy support, user authentication, FTP upload, HTTP post, file transfer resume and more. Homepage: http://curl.haxx.se Original-Maintainer: Ramakrishnan Muthukrishnan <
[email protected]
>

上面的會先說明我是已經安裝過了的,如果沒有安裝應該是類似如下的回顯。
[email protected]:~$ dpkg -s curl
系統沒有安裝軟體包 curl,因而沒有相關的資訊。
使用 dpkg --info (= dpkg-deb --info) 來檢測打包好的檔案,
還可以通過 dpkg --contents (= dpkg-deb --contents) 來列出它們的內容。

那麼安裝就行了sudo apt-get install curl

安裝rvm

用rvm官方推薦的方式安裝curl -L get.rvm.io | bash -s stable

回顯提示我們,RVM被安裝在$HOME/.vrm中;並且需要在終端中載入指令碼$HOME/.rvm/scripts/rvm

[email protected]:~$ curl -L get.rvm.io | bash -s stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   185  100   185    0     0    144      0  0:00:01  0:00:01 --:--:--   906
100 10235  100 10235    0     0   3929      0  0:00:02  0:00:02 --:--:-- 10888
Downloading RVM from wayneeseguin branch stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   131  100   131    0     0     62      0  0:00:02  0:00:02 --:--:--   143
100 1124k  100 1124k    0     0   127k      0  0:00:08  0:00:08 --:--:--  269k

Installing RVM to /home/abbuggy/.rvm/
    RVM PATH line found in /home/abbuggy/.bashrc /home/abbuggy/.zshrc.
    RVM sourcing line found in /home/abbuggy/.bash_profile /home/abbuggy/.zprofile.

# RVM:  Shell scripts enabling management of multiple ruby environments.
# RTFM: https://rvm.io/
# HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)
# Cheatsheet: http://cheat.errtheblog.com/s/rvm/
# Screencast: http://screencasts.org/episodes/how-to-use-rvm

# In case of any issues read output of 'rvm requirements' and/or 'rvm notes'

Installation of RVM in /home/abbuggy/.rvm/ is almost complete:

  * To start using RVM you need to run `source /home/abbuggy/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.

# abbuggy,
#
#   Thank you for using RVM!
#   I sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne

應該請把這句話加在$HOME/.bash_profile檔案中,以便在開啟一個終端會話時候載入RVM
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.

如果對shell變成不熟悉,這裡簡單解釋一下這是幹什麼用的。

[[condition]],兩層的方括號中間括著條件返回條件是不是真。-s是判斷給定的檔案是否存在的命令。這樣一來,不就是在[[ -s "$HOME/.vrm/scripts/vrm"]]判斷剛才安裝的RVM是否存在嗎? 

接下來的&&符號是“短路的與”,當前面的條件是真的時候,執行後面的語句,返回這兩個語句是不是全是真。在這裡,利用了“短路”特性。也就是說當RVM已經安裝的話,執行後面的. "$HOME/.rvm/scripts/rvm"命令。這條命令和source "$HOME/.rvm/scripts/rvm"是一個意思:載入rvm的啟動指令碼。

#符號後面是註釋資訊。

使用RVM

剛才我們通過修改.bash_profile增加的內容需要重新開啟終端視窗時載入。我們有兩個選擇,一個是關閉當前的終端視窗重新開啟,另一個是在當前視窗執行一遍. "$HOME/.rvm/scripts/rvm"。

察看RVM的版本

[email protected]:~$ rvm -v

rvm 1.16.20 (stable) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]

通過rvm requirements命令,可以察看安裝各版本時候的前提條件。其中這句是需要關注的。這是安裝依賴的第三方包,沒有這個安裝不成功豈不是很悲劇?

Additional Dependencies:
# For Ruby / Ruby HEAD (MRI, Rubinius, & REE), install the following:
  ruby: /usr/bin/apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config

這樣一來,安裝ruby的準備工作就完成了。察看當前RVM中已經安裝的ruby版本,現在應該還沒有。
[email protected]:~$ rvm list

rvm rubies

# No rvm rubies installed yet. Try 'rvm help install'.

察看RVM可供安裝的ruby版本
[email protected]:~$ rvm list known
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7-p370
[ruby-]1.8.7[-p371]
[ruby-]1.9.1[-p431]
[ruby-]1.9.2-p180
[ruby-]1.9.2-p290
[ruby-]1.9.2-p318
[ruby-]1.9.2[-p320]
[ruby-]1.9.2-head
[ruby-]1.9.3-preview1
[ruby-]1.9.3-rc1
[ruby-]1.9.3-p0
[ruby-]1.9.3-p125
[ruby-]1.9.3-p194
[ruby-]1.9.3-p286
[ruby-]1.9.3-[p327]
[ruby-]1.9.3-head
[ruby-]2.0.0-preview1
ruby-head

安裝ruby 1.9.3-head,在不發生歧義的情況下方括號內的東西可以不必敲。
[email protected]:~$ rvm install 1.9.3-head

之後等呀等呀自動安裝了1.8.7和1.9.3
[email protected]:~$ rvm list

rvm rubies

   ruby-1.8.7-p371 [ i686 ]
   ruby-1.9.3-head [ i686 ]

# Default ruby not set. Try 'rvm alias create default <ruby>'.

選擇1.9.3作為當前的使用版本,並且設定為預設
[email protected]:~$ rvm use ruby-1.9.3-head --default
Using /home/abbuggy/.rvm/gems/ruby-1.9.3-head

設定好之後察看ruby版本
[email protected]:~$ ruby -v
ruby 1.9.3p327 (2012-11-10) [i686-linux]

察看ruby的路徑,就是RVM幫我們安裝的
[email protected]:~$ which ruby
/home/abbuggy/.rvm/rubies/ruby-1.9.3-head/bin/ruby

短路RVM

剛才是用RVM進行ruby版本管理,當然了通過其他渠道例如apt-get也可以安裝ruby,可以對RVM設定短路以便使用系統預設的ruby版本。

[email protected]:~$ rvm use system
Now using system ruby.
[email protected]:~$ ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-linux]
[email protected]:~$ which ruby
/usr/bin/ruby

解除安裝RVM

不想玩了,我要解除安裝。這個命令會移除$HOME/.rvm目錄下面的所有東西即RVM管理的版本們。

rvm implode

也應該刪除$HOME/.bash_profile中增加的相關內容。

相關推薦

ubuntu安裝使用rvm管理ruby版本

RVM的主要作用是方便的管理系統中的多個ruby版本而不至於混亂。 我們來看看如何安裝RVM,我使用的ubuntu12.04LTS。 準備工作 後面需要使用curl,用dpkg -s curl命令檢查一下系統中有沒有安裝 [email protected]:

ubuntu安裝使用rvm管理ruby

RVM的主要作用是方便的管理系統中的多個ruby版本而不至於混亂。 我們來看看如何安裝RVM,我使用的ubuntu12.04LTS。 準備工作 後面需要使用curl,用dpkg -s c

python編程ubuntu安裝虛擬環境環境配置

port cti virt apt-get 包管理工具 /usr 安裝 wrap bash 1.升級python包管理工具pip pip install --upgrade pip 備註:當你想升級一個包的時候 `pip install --upgrade 包名`

Ubuntu 安裝 MySQL5.7.20(任意版本

相關連結: 在 CentOS 1804 中 使用 yum 安裝 MySQL 5.7 最新版 在 CentOS 1804 中 安裝 MySQL 5.7.20 (或任意MySQL版本) 在 CentOS 1804 中 修改 MySQL 密碼策略 在 CentOS 中 開啟 MySQL 的

Ubuntu安裝zookeeperkafka並配置環境變數

首先安裝zookeeper zookeeper需要jdk環境,請在jdk安裝完成的情況下安裝zookeeper 1.從官網下載zookeeper http://mirror.bit.edu.cn/apache/zookeeper/,版本可以根據自己需要選擇使用,

【智慧合約學習筆記】geth安裝、啟動常用命令,附在Ubuntu安裝Chrome的方法

1、安裝geth: (1)在Ubuntu上安裝: 開啟終端按順序執行以下四條命令 sudo apt-get install software-properties-common sudo add-apt-repository -y ppa:ethereum/ethereu

rvm 用於ruby版本管理

vm是一個命令列工具,可以提供一個便捷的多版本ruby環境的管理和切換。 如果你打算學習ruby/rails, rvm是必不可少的工具之一。 這裡所有的命令都是再使用者許可權下操作的,任何命令最好都不要用sudo. rvm安裝 $ curl -L

SQL server數據庫的在server 2008R2上的安裝基本管理

server 數據庫 SQL server數據庫的在server 2008R2上的安裝及基本管理(一)選擇SQL的數據庫的鏡像文件雙擊setup.ext 執行安裝程序這裏選擇安裝項,並選擇全新安裝安裝的環境監測全部通過因為這裏是使用的破解版的鏡像,所以會自動生成密鑰再一次檢測安裝環境

ubuntu安裝meld工具-(轉自sukhoi27smk)

插件 edit ges -s election load nbsp 輸入 eight Ubuntu下文件/目錄對比的軟件Meld可能有很多用戶還不是很熟悉,下文就給大家介紹如何安裝Meld和移植到Gedit下。具體內容如下所述。 Meld允許用戶查看文件、目錄間的變化。很容

ubuntu安裝mysql

過程 rest imp gen fonts prim alt+ cli word 老規矩,ctrl+alt+t呼出終端, 輸入 sudo apt-get update 更新源,否則在運行下面代碼時會報出有幾個包無法下載,你還是得回來執行這句代碼, 輸入

如何在ubuntu安裝php

關於 輸入密碼 一個 area 測試 ons edit -a edi 如何在ubuntu中安裝php 情釁 | 瀏覽 692 次 發布於2016-05-07 12:36 最佳答案 關於Ubuntu下的LAMP配置步驟:首先要

ubuntu安裝eclipse

views 文件管理 這一 分享 log 啟動命令 -a 安裝jdk tails 上一篇說了安裝jdk的事。於是趁熱打鐵,決定把eclipse也安裝了。 下載這一系列就不用說了。 下載完畢之後: 然後解壓,解壓之後文件剪切到/usr/s

Ubuntu JDK安裝配置

pat usr oracl 下載 mod 配置環境 oracle tar.gz ubun 步驟1:下載jdk 下載地址: JDK:http://www.oracle.com/technetwork/java/javase/downloads/index.html 步驟2:

Ubuntu安裝xampp,以及遠程訪問phpmyadmin遇到的問題

deb log alt 空間不足 存儲空間不足 led 存儲空間 註意 blog   安裝到一半提示killed,表示服務器存儲空間不足   phpmyadmin不允許遠程訪問如何解決,在前一篇隨筆已有介紹   設置自動登錄:   首先在根目錄找到config.sample

ubuntu安裝Python

一行代碼 led 包名 log clu 畫圖 matplot makefile pip 從源代碼編譯安裝 從python官網下載最新版 解壓tar -xzvf Python-3.6.4.tgz,根據版本號修改壓縮包名字 cd Python-2.7.9/ LDFLAGS="

ubuntu安裝使用docker

tar star 自己的 itl 保存 ont 打包 ash linux 關於Docker:   Docker 是一個開源項目,為開發者和系統管理員提供了一個開放的平臺,在任何地方通過打包和運行應用程序作為一個輕量級的容器。Docker 在軟件容器內自動部署應用程序。Doc

在Mac系統安裝配置Apache Tomcat

class 安裝 配置 span pat body 網址 cat 驗證 1.下載Tomcat http://tomcat.apache.org/download-80.cgi .tar.gz結尾和zip均可 2:解壓至想要的文件下 3:配置(註:輸入路徑自定) 使用終端

Ubuntu安裝Docker

sudo res sources blog gpo date 支持 跳過 lib 安裝Ubuntu維護的版本 sudo apt-get install docker.io source /etc/bash_completion.d/docker.io 安裝Docker維護的

thrift安裝python和c++版本調試

最好 查看 IE 分享 -- 通過 error: rom tool 一、安裝過程 1.安裝依賴庫 ]# yum install boost-devel-static libboost-dev libboost-test-dev libboost-program-option

supervisor安裝配置——管理守護進程的福利

npr 文件配置 before var 直接 如果 kill tool mon CentOS7以上直接使用yum安裝即可正常使用小配文件配置supervisor程序並可以多進程方式啟動自己的進守護進程但CentOS6系統使用yum安裝的supervisor不支持使用小配置文