3
3

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 5 years have passed since last update.

Macで複数バージョンのRubyを使用するための環境を構築する方法

Last updated at Posted at 2016-05-30
  • 自分の環境はHomebrewを導入しているので、今回はHomebrewを通してrbenvを入れます。

rbenv

インストール

$ brew install rbenv ruby-build
  • 確認

     $ rbenv --version
     rbenv 1.0.0
    
     $ brew info rbenv
     rbenv: stable 1.0.0 (bottled), HEAD
     Ruby version manager
     https://github.com/rbenv/rbenv#readme
     /usr/local/Cellar/rbenv/1.0.0 (36 files, 61.9K) *
       Poured from bottle on 2016-05-30 at 09:01:46
     From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/rbenv.rb
     ==> Dependencies
     Recommended: ruby-build ✔
     ==> Options
     --without-ruby-build
     	Build without ruby-build support
     --HEAD
     	Install HEAD version
     ==> Caveats
     Rbenv stores data under ~/.rbenv by default. If you absolutely need to
     store everything under Homebrew's prefix, include this in your profile:
       export RBENV_ROOT=/usr/local/var/rbenv
     
     To enable shims and autocompletion, run this and follow the instructions:
       rbenv init
    
     $ brew info rbenv
     rbenv: stable 1.0.0 (bottled), HEAD
     Ruby version manager
     https://github.com/rbenv/rbenv#readme
     /usr/local/Cellar/rbenv/1.0.0 (36 files, 61.9K) *
       Poured from bottle on 2016-05-30 at 09:01:46
     From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/rbenv.rb
     ==> Dependencies
     Recommended: ruby-build ✔
     ==> Options
     --without-ruby-build
     	Build without ruby-build support
     --HEAD
     	Install HEAD version
     ==> Caveats
     Rbenv stores data under ~/.rbenv by default. If you absolutely need to
     store everything under Homebrew's prefix, include this in your profile:
       export RBENV_ROOT=/usr/local/var/rbenv
     
     To enable shims and autocompletion, run this and follow the instructions:
       rbenv init
     LowSE01MacBookPro:pyenv LowSE01$
     LowSE01MacBookPro:pyenv LowSE01$
     LowSE01MacBookPro:pyenv LowSE01$ brew info ruby-build
     ruby-build: stable 20160426, HEAD
     Install various Ruby versions and implementations
     https://github.com/rbenv/ruby-build
     /usr/local/Cellar/ruby-build/20160426 (215 files, 124.6K) *
       Built from source on 2016-06-02 at 12:57:56
     From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/ruby-build.rb
     ==> Dependencies
     Recommended: autoconf ✔, pkg-config ✔, openssl ✔
     ==> Options
     --without-autoconf
     	Build without autoconf support
     --without-openssl
     	Build without openssl support
     --without-pkg-config
     	Build without pkg-config support
     --HEAD
     	Install HEAD version
    

パス設定

  • パスを通します

     $ echo 'export RBENV_ROOT=/usr/local/var/rbenv' >> ~/.bash_profile
     $ echo 'eval "$(rbenv init -)"'          >> ~/.bash_profile
     $ source ~/.bash_profile
    

ruby

インストール

  • インストール可能バージョンの確認

     $ rbenv install --list
    
  • インストール実行

     $ rbenv install 2.3.0
     
     Downloading ruby-2.3.0.tar.bz2...
     -> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.0.tar.bz2
     Installing ruby-2.3.0...
     Installed ruby-2.3.0 to /Users/LowSE01/.rbenv/versions/2.3.0
    

デフォルトバージョン指定

  • デフォルトで使用するバージョンを指定する

     rbenv global 2.3.0
    
  • 確認

     $ ruby --version
     ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin14]
    
    • VersionがインストールしたものになっていればOK。

IntelliJ + Ruby

プラグイン

  • 名前そのまま、「Ruby」ってプラグインがあったのでインストール。
3
3
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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?