Help us understand the problem. What is going on with this article?

AWSにRubyバージョン切り替えツールを導入する

More than 1 year has passed since last update.

はじめに

AWSにrbenvを導入するときに行った手順をメモに残すものである。

rbenvをインストールする

GithubのREADMEを参考に以下のコマンドを実行する。

Githubからrbenvをダウンロードして設定を行う

$ git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
Cloning into '/home/ec2-user/.rbenv'...
remote: Counting objects: 2723, done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 2723 (delta 3), reused 7 (delta 1), pack-reused 2714
Receiving objects: 100% (2723/2723), 520.78 KiB | 754.00 KiB/s, done.
Resolving deltas: 100% (1703/1703), done.
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
$ source ~/.bash_profile 

rbenvのバージョンを確認する

$ rbenv -v
rbenv 1.1.1-33-ge55e3c0

ruby-buildを導入する

Rubyをインストールするときに必要となる。

$ git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
Cloning into '/home/ec2-user/.rbenv/plugins/ruby-build'...
remote: Counting objects: 8867, done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 8867 (delta 8), reused 18 (delta 2), pack-reused 8843
Receiving objects: 100% (8867/8867), 1.86 MiB | 535.00 KiB/s, done.
Resolving deltas: 100% (5684/5684), done.

安定版のruby2.4.2をインストールする

$ rbenv install 2.4.2
Downloading ruby-2.4.2.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.2.tar.bz2
Installing ruby-2.4.2...
Installed ruby-2.4.2 to /home/ec2-user/.rbenv/versions/2.4.2

ruby2.4.2に切り替える

$ rbenv global 2.4.2
$ rbenv rehash

バージョンが切り替わったことを確認

$ ruby -v
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]

まとめ

rbenvを使うとrubyのバージョンが切り替えが便利で最高!

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした