1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

RVMの使い方

Posted at

Rubyのバージョン変更管理システム「RVM」の使い方を簡単にご説明します。

0. RVMとは?

基本的には最新版を使うのが一番良いです。
ただし、開発済のプログラムが違うバージョンだと動かなかったりするので、

プロジェクトXでは、Ruby 2.6.3 を。
プロジェクトYでは、Ruby 2.5.1 を使用する

というようなことがあります。

その際逐一、プロジェクトごとにRubyのバージョンを再インストール・アンインストールしなくても済むように、コマンド一つでバージョンを切り替えられる便利ツールが用意されています。

その便利ツールの一つが「RVM」です。
(同じようなツールに「rbenv」もあります。完全に好みの問題ですが、なんとなくRVMの方が主流な気がします)

インストールはこちらから可能です。

1. RVMコマンド実行手順

$ rvm listを実行し、現在使用可能なRubyを表示する

$ rvm list
=* ruby-2.6.3 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

この場合は、ruby2.6.3しか使用可能ではないため、もし2.5.〜を使いたい場合は以下を実行する

$rvm install [使いたいバージョン(数字のみ)]

$rvm install 2.5.1
Warning, new version of rvm available・・・
・・・(省略)・・・
Ruby was built without documentation, to build it run: rvm docs generate-ri

再度$ rvm listで使用可能なRubyのバージョンを確認

$ rvm list
=> ruby-2.5.1 [ x86_64 ]
 * ruby-2.6.3 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

$ rvm use [使いたいバージョン(数字のみ)]

$ rvm use 2.5.1
Using /home/ec2-user/.rvm/gems/ruby-2.5.1

$ ruby -vで先ほどのバージョンが適応されているかどうか確認

$ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]

$ rvm listで、使用しているRubyが絞り込めているかどうか確認

$ rvm list
=> ruby-2.5.1 [ x86_64 ]
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?