Home
Packages
Forums
Wiki
GitLab
Security
AUR
Download
コンテンツにスキップ
メインメニュー
メインメニュー
サイドバーに移動
非表示
案内
メインページ
目次
コミュニティに貢献
最近の出来事
おまかせ表示
特別ページ
交流
ヘルプ
貢献
最近の更新
最近の議論
新しいページ
統計
リクエスト
ArchWiki
検索
検索
表示
アカウント作成
ログイン
個人用ツール
アカウント作成
ログイン
RVMのソースを表示
ページ
議論
日本語
閲覧
ソースを閲覧
履歴を表示
ツール
ツール
サイドバーに移動
非表示
操作
閲覧
ソースを閲覧
履歴を表示
全般
リンク元
関連ページの更新状況
ページ情報
表示
サイドバーに移動
非表示
←
RVM
あなたには「このページの編集」を行う権限がありません。理由は以下の通りです:
この操作は、次のグループに属する利用者のみが実行できます:
登録利用者
。
このページのソースの閲覧やコピーができます。
[[Category:開発]] [[de:RVM]] [[en:RVM]] {{Related articles start}} {{Related|Rbenv}} {{Related|Chruby}} {{Related|Ruby}} {{Related articles end}} [http://rvm.io/ RVM] (Ruby Version Manager) はインタプリタから gem のセットまで複数の [[Ruby]] 環境を簡単にインストール・管理・操作できるコマンドラインツールです。 同じように使えるアプリケーションも存在します: [[rbenv]]。 == RVM のインストール == インストール方法はとても簡単で、Arch Linux 以外のディストリビューションでも大体同じです。2つの選択肢があります。システム全体でインストールするか、ユーザー個別でインストールするかです。本番サーバーや、マシンにユーザーが一人しかいない場合、前者を選びます。root 権限が必要になります。(開発用マシンなど) マシン上にユーザーが複数存在する場合は後者が推奨されます。どちらを選べばいいのかわからないときは、シングルユーザーインストールを選んで下さい。 RVM のインストールについては上流の指示通りにすれば問題ありません。複数の ruby を動作させるために、Arch Linux にインストールする必要があるパッケージをインストールスクリプトが教えてくれます。主に ruby をコンパイルするのに必要な gcc などです。 gem による RVM のインストールは推奨されていません。この記事では [http://rvm.io/rvm/install/ 推奨文献] を元に Arch Linux で動作させるための多少の修正を加えています。 === 要件 === インストールを始める前に、以下をインストールしてください: $ pacman -S git curl === シングルユーザーインストール === {{Note|こちらの方法ではホームディレクトリ ({{ic|~/.rvm}}) にインストールするので、({{ic|/usr}} にある) Arch の標準の ruby パッケージは操作しません。}} 大抵の場合、ユーザーのホームディレクトリに独立した RVM をインストールする、シングルユーザーインストールが推奨されます。 RVM のドキュメントで推奨されているスクリプトを使ってインストールしてください。RVM をインストールするユーザー (開発に使っている通常ユーザー) でスクリプトを実行します。 スクリプトを実行する前に、チェックを行なって下さい: $ curl -L get.rvm.io > rvm-install ファイルを確認したら、次のコマンドで実行します: $ bash < ./rvm-install スクリプトの実行が完了したら、以下の行を {{ic|~/.bash_login}} または {{ic|~/.bashrc}} (あるいは {{ic|~/.zprofile}} など) の末尾に追加してください: $ <nowiki>[[ -s "$HOME/.rvm/scripts/rvm" ]]</nowiki> && source "$HOME/.rvm/scripts/rvm" それから、現在のシェルまたはターミナルセッションを閉じて、新しいシェルを開いて下さい。以下のコマンドで {{ic|~/.bash_login}} をリロードすることができますが、基本的にはシェルやターミナルを一度閉じてから新しいシェルを開くことが推奨されています: $ source ~/.bash_login === マルチユーザーインストール === {{Note|こちらの方法では {{ic|/usr/local/rvm}} にインストールするので、({{ic|/usr}} にある) Arch の標準の ruby パッケージは操作しません。}} システム全体でのインストールもシングルユーザーインストールと手順はあまり変わりません。ただし、インストールスクリプトは sudo で実行します。root で直接インストーラを実行してはいけません。以下を実行してください (特定のバージョンをインストールするときは ''stable'' を ''--version 1.13.0'' などに置き換えて下さい): $ curl -L get.rvm.io | sudo bash -s stable スクリプトの実行が完了したら、ユーザーを 'rvm' グループに追加してください (インストーラは rvm グループへのユーザーの追加までは自動で行いません。管理者が行う必要があります)。追加するユーザーごとに、以下を実行: # usermod -a -G rvm <user> グループの追加が反映されるのはログイン時だけです。一度ユーザーをログアウトしてから、再度ログインしてください。 {{Note|{{ic|[ [ -s $HOME/.rvm/scripts/rvm ] ] && source $HOME/.rvm/scripts/rvm}} の {{ic|$HOME}} は {{ic|/usr/local}} に置き換えて下さい。}} (シングルユーザーインストールと違って) RVM はシステム上の全てのユーザーで自動的に設定されます。ログイン時に {{ic|/etc/profile.d/rvm.sh}} をロードすることで設定されます。Arch Linux はデフォルトで {{ic|/etc/profile}} から {{ic|/etc/profile.d/}} ディレクトリにある全てのファイルをロードするようになっています。 マルチユーザー rvm で gem をインストールする前に、{{ic|/etc/gemrc}} に {{ic|gem: --user-install}} という行がないことを確認してください。存在する場合は、コメントアウトしてください。そうしないと gem が間違った場所へインストールされてしまいます。 sudo コマンドを使用するのはインストールのときだけです。マルチユーザー設定では、sudo が必要な操作をするときは ''rvmsudo'' コマンドを使うことになっています。コアインストールが完了した後に、''rvmsudo'' コマンドを使う必要があることは非常に稀で、せいぜい RVM 自体のアップデートのときくらいです。インストール後に sudo を使う機会はありません。以下のコマンドで RVM をアップデートするときだけ ''rvmsudo'' が必要になります: $ rvmsudo rvm get head sudo によって RVM が破壊されないように、{{ic|/etc/sudoers}} ファイルに以下の設定を追加してもよいでしょう。次のコマンドを実行してください: {{ic|#su -c visudo}}。 {{bc|1= ## Cmnd alias specification Cmnd_Alias RVM = /usr/local/rvm/rubies/<ruby_interpreter>/bin/gem, \ /usr/local/rvm/rubies/<another_ruby_interpreter>/bin/gem, \ /usr/local/rvm/bin/rvm ## User privilege specification root ALL=(ALL) ALL ## Uncomment to allow members of group wheel to execute any command %wheel ALL=(ALL) ALL, !RVM }} ''<ruby_interpreter>'' は ruby-1.9.2-p290 などに置き換えて下さい。 == インストールの後 == インストール後、以下のコマンドで問題がないか確認します: $ type rvm | head -n1 以下のように応答するはずです: rvm is a function {{ic|rvm: not found}} と返ってくる場合、{{ic|~/.bash_login}} (上の設定を追加したファイル) を読み込んで下さい: $ . ~/.bash_login rvm が機能するかどうか確認: $ rvm notes 最後に、必要なパッケージがあるかどうか確認してください (出力された指示に従って下さい): $ rvm requirements RVM をアップグレードしたときは、''rvm notes'' と ''rvm requirements'' を毎回実行するようにしてください。主要な変更があった場合や、必要なパッケージが増えた時にそれを知ることができます。 === 追加設定 === {{ic|~/.bashrc}} ファイルに以下の行を追加することで便利な機能が得られます: {{bc|1= # Display the current RVM ruby selection PS1="\$(/usr/local/rvm/bin/rvm-prompt) $PS1" # RVM bash completion <nowiki>[[ -r /usr/local/rvm/scripts/completion ]]</nowiki> && . /usr/local/rvm/scripts/completion }} もしくはシングルユーザーで使っている場合: {{bc|1= # RVM bash completion <nowiki>[[ -r "$HOME/.rvm/scripts/completion" ]]</nowiki> && source "$HOME/.rvm/scripts/completion" }} == RVM を使う == RVM のドキュメントはとてもわかりやすくなっていますが、以下では RVM の使用例を少しだけお見せします。 === Ruby === ==== 環境のインストール ==== インストールできる Ruby 環境を確認するには、次を実行: $ rvm list known 環境をインストールするには、次を実行: $ rvm install <ruby_version> 例えば、Ruby 1.9.2 をインストールするには以下のコマンドを実行: $ rvm install 1.9.2 RVM をインストールした場所に Ruby 1.9.2 がダウンロード・設定・インストールされます。シングルユーザーインストールをした場合、{{ic|~/.rvm/rubies/1.9.2}} になります。 次を実行することでデフォルトの ruby インタプリタを定義できます: $ rvm use <ruby_version> --default 上記を実行しない場合、(pacman で ruby をインストールしていれば) デフォルト環境は {{ic|/usr}} のシステムの ruby になります。 ==== 環境の切り替え ==== 別の環境に切り替えるには次を実行: $ rvm use <ruby_version> 例えば Ruby 1.8.7 に切り替えるには次のコマンドを実行してください (''use'' フラグはなくてもかまいません): $ rvm 1.8.7 切り替えが完了したというメッセージが表示されます。以下のコマンドで確認できます: $ ruby --version 切り替えた環境は現在のシェルでしか使われないので注意してください。新しくシェルを開いて、別の環境を選択することで、別々の環境を同時に使うことができます。 上で説明したようにデフォルトのインタプリタを設定した場合、以下のようにしてデフォルトの環境に切り替えられます: $ rvm default ==== 標準 Ruby ==== RVM の外にある ruby インタプリタ (Arch Linux のパッケージで {{ic|/usr}} にインストールした ruby) を使いたい場合、次のコマンドで切り替えられます: $ rvm system ==== 環境の確認 ==== インストールした Ruby 環境を確認するには、以下のコマンドを実行: $ rvm list 複数の ruby をインストールしていた場合、以下のようなリストが表示されます: rvm Rubies jruby-1.5.0 [ [i386-java] ] => ruby-1.8.7-p249 [ i386 ] ruby-1.9.2-head [ i386 ] System Ruby system [ i386 ] 現在有効になっている環境は矢印で示されます。上記の場合、Ruby 1.8.7 です。次を実行することでも確認できます: $ ruby --version ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux] === Gemset === RVM has a valued feature called gemsets which enables you to store different sets of gems in compartmentalized independent ruby setups. This means that ruby, gems and irb are all separate and self-contained from the system and each other. ==== 作成 ==== Gemsets must be created before being used. To create a new gemset for the current ruby, do this: $ rvm use <ruby_version> $ rvm gemset create <gemset_name> Alternatively, if you prefer the shorthand syntax offered by rvm use, employ the --create option like so: $ rvm use <ruby_version>@<gemset_name> --create You can also specify a default gemset for a given ruby interpreter, by doing: $ rvm use <ruby_version>@<gemset_name> --default ==== 使用 ==== Tip: remove gems that reside in system priore RVM installation with: $ gem list --local | awk '{print "gem uninstall " $1}' | bash and check what's left: $ gem list --local gemset を使うには: $ rvm gemset use <gemset_name> You can switch to a gemset as you start to use a ruby, by appending @<gemset_name> to the end of the ruby selector string: $ rvm use <ruby_version>@<gemset_name> ===== ノート ===== When you install a ruby environment, it comes with two gemsets out of the box, their names are ''default'' and ''global''. You will usually find in the latter some pre-installed common gems, while the former always starts empty. A little bit about where the default and global gemsets differ: When you do not use a gemset at all, you get the gems in the default set. If you use a specific gemset (say @testing), it will inherit gems from that ruby's @global. The global gemset is to allow you to share gems to all your gemsets. ==== Gem ==== Within a gemset, you can utilize usual RubyGems commands $ gem install <gem> to add, $ gem uninstall <gem> to remove gems, and $ gem list to view installed ones. If you are deploying to a server, or you do not want to wait around for rdoc and ri to install for each gem, you can disable them for gem installs and updates. Just add these two lines to your ~/.gemrc or /etc/gemrc: install: --no-document update: --no-document ==== 確認 ==== 現在の gemset の名前を確認するには: $ rvm gemset name To list all named gemsets for the current ruby interpreter: $ rvm gemset list To list all named gemsets for all interpreters: $ rvm gemset list_all ==== 削除 ==== This action removes the current gemset: $ rvm gemset use <gemset_name> $ rvm gemset delete <gemset_name> By default, rvm deletes gemsets from the currently selected Ruby interpreter. To delete a gemset from a different interpreter, say 1.9.2, run your command this way: $ rvm 1.9.2 do gemset delete <gemset_name> ==== 消去 ==== This action removes all gems installed in the gemset: $ rvm gemset use <gemset_name> $ rvm gemset empty <gemset_name> === RVM === ==== アップデート ==== 最新のリリースバージョンにアップグレードするには: $ rvm get latest Upgrading to the latest repository source version (the most bugfixes): $ rvm get head マルチユーザー設定のときは rvmsudo を使って下さい。アップデートは頻繁に。 ==== アンインストール ==== RVM を消去するには次を実行: $ rvm implode === 参考資料 === This is just a simple introduction to switching ruby versions with RVM and managing different set of gems in different environments. There is lots more that you can do with it! For more information, consult the very comprehensive RVM documentation. [https://rvm.beginrescueend.com/rvm/basics/ This page] is a good place to start. == トラブルシューティング == You will need to take care with rvm installations, since ArchLinux is very well updated, and some earlier ruby's patchlevels do not like it. RVM many times do not choose the latest patchlevel version to install, and you'll need to check manually on the [http://www.ruby-lang.org/en/news/ ruby website], and force RVM to install it. ==== "data definition has no type or storage class" ==== This appears to be specific to 1.8.7, but if you get this error while compiling the following steps will fix your problem: $ cd src/ruby-1.8.7-p334/ext/dl $ rm callback.func $ touch callback.func $ ruby mkcallback.rb >> callback.func $ rm cbtable.func $ touch cbtable.func $ ruby mkcbtable.rb >> cbtable.func Naturally, substitute the actual build path to your source, which will be something like ~/.rvm/src/. ==== Ruby 1.8.x が RVM でコンパイルできない ==== This is a known issue on Arch Linux, and is caused by a problem with openssl. Arch uses openssl 1.0, lower patchlevels of 1.8.7 assumes 0.9. Certain patch levels may not build (p352 for example), p299 should work fine and can be installed using the following command: $ rvm remove 1.8.7 $ rvm install 1.8.7-p299 Another approach is to install local openssl via RVM: $ rvm pkg install openssl $ rvm remove 1.8.7 $ rvm install 1.8.7 -C --with-openssl-dir=$HOME/.rvm/usr It may be necessary to patch 1.8.7: $ wget http://redmine.ruby-lang.org/attachments/download/1931/stdout-rouge-fix.patch $ rvm remove 1.8.7 $ rvm install --patch Downloads/stdout-rouge-fix.patch ruby-1.8.7-p352 ==== Ruby 1.9.1 が RVM でコンパイルできない ==== Like with 1.8.x, earlier patchlevels do not like the OpenSSL 1.0. Then you can use the very same solution above, by installing openssl locally on RVM. $ rvm pkg install openssl $ rvm remove 1.9.1 $ rvm install 1.9.1 -C --with-openssl-dir=$HOME/./rvm/usr The patchlevels >p378 have a problem with gem paths, when $GEM_HOME is set. The problem is known and fixed in 1.9.2. (http://redmine.ruby-lang.org/issues/3584). If you really need 1.9.1 please use p378. $ rvm install 1.9.1-p378 -C --with-openssl-dir=$HOME/.rvm/usr == 参照 == * [http://rvm.io/ RVM プロジェクトウェブサイト] * [[Ruby on Rails#Rails パーフェクトセットアップ|Rails パーフェクトセットアップ]]
このページで使用されているテンプレート:
テンプレート:Bc
(
ソースを閲覧
)
テンプレート:Grp
(
ソースを閲覧
)
テンプレート:Ic
(
ソースを閲覧
)
テンプレート:META Related articles start
(
ソースを閲覧
)
テンプレート:Note
(
ソースを閲覧
)
テンプレート:Pkg
(
ソースを閲覧
)
テンプレート:Related
(
ソースを閲覧
)
テンプレート:Related articles end
(
ソースを閲覧
)
テンプレート:Related articles start
(
ソースを閲覧
)
RVM
に戻る。
検索
検索
RVMのソースを表示
話題を追加