複数のrubyを管理したい場合、バージョン管理を楽に行いたい場合はrvm(Ruby enVironment Manager)の利用をオススメします。
実施環境:CentOS 6.2
rvmのインストール
1 |
bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer ) |
/etc/profile.d/rvm.shが作成されます。このshが「どこにパスを通すか」をコントロールしており、
複数バージョンのrubyを容易に切り替えられる、という仕掛けです。
sourceコマンドを実行し、rvm.shを反映させましょう。
1 |
source /etc/profile.d/rvm.sh |
パスが通ればrvmコマンドを使うことが出来るようになります。
ruby 1.9.3のインストール
1 |
rvm install 1.9.3 |
インストール可能なバージョンを調べるには
1 |
rvm list known |
結果は下記のようになりました
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
[ruby-]1.8.6[-p420] [ruby-]1.8.7[-p371] [ruby-]1.9.1[-p431] [ruby-]1.9.2[-p320] [ruby-]1.9.3-p125 [ruby-]1.9.3-p194 [ruby-]1.9.3-p286 [ruby-]1.9.3-p327 [ruby-]1.9.3-p362 [ruby-]1.9.3[-p374] [ruby-]1.9.3-head [ruby-]2.0.0-rc1 ruby-head # GoRuby goruby # TheCodeShop - MRI experimental patches tcs # jamesgolick - All around gangster jamesgolick # Minimalistic ruby implementation - ISO 30170:2012 mruby[-head] # JRuby jruby-1.2.0 jruby-1.3.1 jruby-1.4.0 jruby-1.6.5.1 jruby-1.6.6 jruby-1.6.7.2 jruby-1.6.8 jruby[-1.7.2] jruby-head # Rubinius rbx-1.0.1 rbx-1.1.1 rbx-1.2.3 rbx-1.2.4 rbx[-head] rbx-2.0.testing rbx-2.0.0-rc1 # Ruby Enterprise Edition ree-1.8.6 ree[-1.8.7][-2012.02] # Kiji kiji # 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 # Opal opal # IronRuby ironruby[-1.1.3] ironruby-head |
利用するRubyのバージョンを明示します
1 |
rvm use 1.9.3 |
これで1.9.3を利用可能となりました。
複数インストールする場合は
1 |
rvm install 1.8.2 |
を実行し、1.8.2を利用する場合は
1 |
rvm use 1.8.2 |
として下さい。
rvmのヘルプを気まぐれで翻訳しておきます
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
* https://rvm.io/ * https://github.com/wayneeseguin/rvm/ == DESCRIPTION: RVM は Ruby 環境マネージャです (rvm). It manages Ruby application environments and enables switching between them. == インストール方法 curl -L https://get.rvm.io | bash -s stable [--ruby] [--rails] [--trace] stable :: 安定したRVMをインストールする, サーバ向け. --ruby :: 最新のrubyバージョンをインストールする --rails :: デフォルトのgemsetにgem railsをインストールする --trace ::インストールのトレースを表示する もっと情報が必要な場合は右記参照: https://rvm.io/rvm/install/ == 使い方 rvm [Flags] [Options] Action [Implementation[,Implementation[,...]] == Flags --default :: with 'rvm use X', sets the default ruby for new shells to X. --debug :: デバグ情報を表示する --trace :: rvm実行内容を全て表示する --force :: 古いインストールとソースを削除し、インストールする --summary :: rubydoと共に使用されコマンドラインサマリーを表示する --latest :: with gemset --dump skips version strings for latest gem. --gems :: with uninstall/remove removes gems with the interpreter. --docs :: with install, attempt to generate ri after installation. --reconfigure :: Force ./configure on install even if Makefile already exists. --skip-gemsets :: with install, skip the installation of default gemsets. == Options -v|--version :: 現在のシェルで呼び出されるrvm versionを表示 -l|--level :: rvm use / installで利用するパッチレベル --bin :: バイナリの配置先 (~/.rvm/bin/) -S :: 実行するスクリプトファイルを指定 (rubydo) -e :: コマンドラインからコードを実行 --gems :: 'gems_flag'を設定する。gemの削除で使用。 --archive :: 'archive_flag'を設定。 archiveの削除で使用 --patch :: With MRI Rubies you may specify one or more full paths to patches for multiple, specify comma separated: --patch /.../.../a.patch[%prefix],/.../.../.../b.patch 'prefix' is an optional argument, which will be bypassed to the '-p' argument of the 'patch' command. It is separated from patch file name with '%' symbol. -C|--configure :: custom configure options. If you need to pass several configure options then append them comma separated: -C --...,--...,--... --nice :: process niceness (for slow computers, default 0) --ree-options :: Options passed directly to ree's './installer' on the command line. --with-rubies :: Specifies a string for rvm to attempt to expand for set operations. == Action (Note: for most actions, 'rvm help action-name' may provide more information.) *usage* :: 使用方法を表示 version :: rvm_pathにインストールされたrvm versionを表示 use :: 現在のシェルで利用するrubyのバージョンを指定 reload :: rvm sourceをリロード (rvm sourceを変更した後に使うとイイ) implode :: (seppuku) removes the rvm installation completely. This means everything in $rvm_path (~/.rvm || /usr/local/rvm). This does not touch your profiles. However, this means that you must manually clean up your profiles and remove the lines which source RVM. get :: {head,stable} upgrades rvm to latest head or stable version. Check 'rvm help get' for more details. (If you experience bugs try this first with head version, then ask for help in #rvm on irc.freenode.net and hang around) reset :: remove current and stored default & system settings. (If you experience odd behavior try this second) info :: show the *current* environment information for current ruby current :: print the *current* ruby version and the name of any gemset being used. debug :: show info plus additional information for common issues install :: install one or many ruby versions See also: https://rvm.io/rubies/installing/ uninstall :: uninstall one or many ruby versions, leaves their sources remove :: uninstall one or many ruby versions and remove their sources migrate :: Lets you migrate all gemsets from one ruby to another. upgrade :: Lets you upgrade from one version of a ruby to another, including migrating your gemsets semi-automatically. wrapper :: generates a set of wrapper executables for a given ruby with the specified ruby and gemset combination. Used under the hood for passenger support and the like. cleanup :: Lets you remove stale source folders / archives and other miscellaneous data associated with rvm. repair :: Lets you repair parts of your environment e.g. wrappers, env files and and similar files (e.g. general maintenance). snapshot :: Lets you backup / restore an rvm installation in a lightweight manner. disk-usage :: Tells you how much disk space rvm install is using. tools :: Provides general information about the ruby environment, primarily useful when scripting rvm. docs :: Tools to make installing ri and rdoc documentation easier. rvmrc :: Tools related to managing rvmrc trust and loading. do :: runs an arbitrary command against specified and/or all rubies tests :: runs 'rake test' across selected ruby versions specs :: runs 'rake spec' across selected ruby versions monitor :: Monitor cwd for testing, run `rake {spec,test}` on changes. gemset :: gemsets: https://rvm.io/gemsets/ rubygems :: Switches the installed version of rubygems for the current ruby. gemdir :: display the path to the current gem directory (GEM_HOME). srcdir :: display the path to rvm source directory (may be yanked) fetch :: Performs an archive / src fetch only of the selected ruby. list :: show currently installed rubies, interactive output. https://rvm.io/rubies/list/ pkg :: Install a dependency package {readline,iconv,zlib,openssl} https://rvm.io/packages/ notes :: Display notes, with operating system specifics. export :: Temporarily set an environment variable in the current shell. unexport :: Undo changes made to the environment by 'rvm export'. requirements :: Shows additional OS specific dependencies/requirements for building various rubies. mount :: Install rubies from external locations 'rvm help mount'. == Implementation *ruby* :: MRI/YARV Ruby (The Gold Standard) {1.8.6,1.8.7,1.9.1,1.9.2...} jruby :: JRuby, Ruby interpreter on the Java Virtual Machine. rbx :: Rubinius ree :: Ruby Enterprise Edition, MRI Ruby with several custom patches for performance, stability, and memory. macruby :: MacRuby, insanely fast, can make real apps (Mac OS X Only). maglev :: GemStone Ruby, awesome persistent ruby object store. ironruby :: IronRuby, NOT supported yet. Looking for volunteers to help. system :: use the system ruby (eg. pre-rvm state) default :: use rvm set default ruby and system if it hasn't been set. https://rvm.io/rubies/default/ == Resources: https://rvm.io/ https://www.pivotaltracker.com/projects/26822 == Contributions: Any and all contributions offered in any form, past present or future, to the RVM project are understood to be in complete agreement and acceptance with the Apache License v2.0. == LICENSE: Copyright (c) 2009-2011 Wayne E. Seguin Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. |