How to install Ruby with rbenv

## Install rbenv with Homebrew
###1. Install rbenv (rbenv is able to manage ruby versions.)

```
186590cdc78d:~ user$ brew install rbenv
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
historian                                osmium-tool
==> Updated Formulae
aws-elasticbeanstalk       httrack                    ocproxy
batik                      hugo                       par2
bmake                      icdiff                     pipes-sh
cake                       imlib2                     poco
catimg                     iproute2mac                potrace
cfr-decompiler             jenkins                    ppsspp
cgdb                       kobalt                     purescript
clipper                    kubernetes-helm            pyqt
conan                      latex2rtf                  rgbds
consul                     lean-cli                   rtags
convox                     less                       sdlpop
creduce                    lft                        sip
dbt                        llvm                       sratom
dbus-glib                  llvm@3.9                   stk
flashrom                   log4cpp                    sylpheed
flow                       logtalk                    tomcat
folly                      lrzip                      unbound
fossil                     mailhog                    urh
fox                        mercurial                  vaulted
fstar                      mutt                       vim
fzy                        mysql-sandbox              you-get
giter8                     nagios                     youtube-dl
gtkspell3                  nodebrew                   zebra
httpie                     nu

==> Installing dependencies for rbenv: autoconf, pkg-config, ruby-build
==> Installing rbenv dependency: autoconf
==> Downloading https://homebrew.bintray.com/bottles/autoconf-2.69.sierra.bottle
######################################################################## 100.0%
==> Pouring autoconf-2.69.sierra.bottle.4.tar.gz
==> Caveats
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/autoconf
==> Summary
🍺  /usr/local/Cellar/autoconf/2.69: 70 files, 3.0MB
==> Installing rbenv dependency: pkg-config
==> Downloading https://homebrew.bintray.com/bottles/pkg-config-0.29.2.sierra.bo
######################################################################## 100.0%
==> Pouring pkg-config-0.29.2.sierra.bottle.tar.gz
🍺  /usr/local/Cellar/pkg-config/0.29.2: 11 files, 627KB
==> Installing rbenv dependency: ruby-build
==> Using the sandbox
==> Downloading https://github.com/rbenv/ruby-build/archive/v20170405.tar.gz
==> Downloading from https://codeload.github.com/rbenv/ruby-build/tar.gz/v201704
######################################################################## 100.0%
==> ./install.sh
🍺  /usr/local/Cellar/ruby-build/20170405: 342 files, 181.9KB, built in 6 seconds
==> Installing rbenv
==> Downloading https://homebrew.bintray.com/bottles/rbenv-1.1.0.sierra.bottle.t
######################################################################## 100.0%
==> Pouring rbenv-1.1.0.sierra.bottle.tar.gz
🍺  /usr/local/Cellar/rbenv/1.1.0: 36 files, 63.2KB
186590cdc78d:~ tomtan$ brew install ruby-build
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
planck

Warning: ruby-build-20170405 already installed
186590cdc78d:~ user$ echo 'export PATH="$HOME/.rbenv/shims:$PATH"' >> ~/.bash_profile
186590cdc78d:~ user$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
186590cdc78d:~ user$ source ~/.bash_profile
186590cdc78d:~ user$ rbenv -v
rbenv 1.1.0 #Complete installation of rbenv
```
### (2.Confirm if rbenv and ruby-build are latest version)
```
186590cdc78d:~ user$ brew upgrade rbenv ruby-build
Error: rbenv 1.1.0 already installed
Error: ruby-build 20170405 already installed
```
### 3.Check ruby version using following command
```
186590cdc78d:~ user$ rbenv install -l
Available versions:
  1.8.5-p52
  1.8.5-p113
  1.8.5-p114
  1.8.5-p115
  1.8.5-p231
  1.8.6
  1.8.6-p36
  1.8.6-p110
  1.8.6-p111
  1.8.6-p114
  1.8.6-p230
  1.8.6-p286
  1.8.6-p287
  1.8.6-p368
  1.8.6-p369
  1.8.6-p383
  1.8.6-p388
  1.8.6-p398
  1.8.6-p399
  1.8.6-p420
  1.8.7-preview1
  1.8.7-preview2
  1.8.7-preview3
  1.8.7-preview4
  1.8.7
  1.8.7-p17
  1.8.7-p22
  1.8.7-p71
  1.8.7-p72
  1.8.7-p160
  1.8.7-p173
  1.8.7-p174
  1.8.7-p248
  1.8.7-p249
  1.8.7-p299
  1.8.7-p301
  1.8.7-p302
  1.8.7-p330
  1.8.7-p334
  1.8.7-p352
  1.8.7-p357
  1.8.7-p358
  1.8.7-p370
  1.8.7-p371
  1.8.7-p373
  1.8.7-p374
  1.8.7-p375
  1.9.0-0
  1.9.0-1
  1.9.0-2
  1.9.0-3
  1.9.0-4
  1.9.0-5
  1.9.1-preview1
  1.9.1-preview2
  1.9.1-rc1
  1.9.1-rc2
  1.9.1-p0
  1.9.1-p129
  1.9.1-p243
  1.9.1-p376
  1.9.1-p378
  1.9.1-p429
  1.9.1-p430
  1.9.1-p431
  1.9.2-preview1
  1.9.2-preview3
  1.9.2-rc1
  1.9.2-rc2
  1.9.2-p0
  1.9.2-p136
  1.9.2-p180
  1.9.2-p290
  1.9.2-p318
  1.9.2-p320
  1.9.2-p326
  1.9.2-p330
  1.9.3-dev
  1.9.3-preview1
  1.9.3-rc1
  1.9.3-p0
  1.9.3-p105
  1.9.3-p125
  1.9.3-p194
  1.9.3-p286
  1.9.3-p327
  1.9.3-p362
  1.9.3-p374
  1.9.3-p385
  1.9.3-p392
  1.9.3-p426
  1.9.3-p429
  1.9.3-p448
  1.9.3-p484
  1.9.3-p545
  1.9.3-p547
  1.9.3-p550
  1.9.3-p551
  2.0.0-dev
  2.0.0-preview1
  2.0.0-preview2
  2.0.0-rc1
  2.0.0-rc2
  2.0.0-p0
  2.0.0-p195
  2.0.0-p247
  2.0.0-p353
  2.0.0-p451
  2.0.0-p481
  2.0.0-p576
  2.0.0-p594
  2.0.0-p598
  2.0.0-p643
  2.0.0-p645
  2.0.0-p647
  2.0.0-p648
  2.1.0-dev
  2.1.0-preview1
  2.1.0-preview2
  2.1.0-rc1
  2.1.0
  2.1.1
  2.1.2
  2.1.3
  2.1.4
  2.1.5
  2.1.6
  2.1.7
  2.1.8
  2.1.9
  2.1.10
  2.2.0-dev
  2.2.0-preview1
  2.2.0-preview2
  2.2.0-rc1
  2.2.0
  2.2.1
  2.2.2
  2.2.3
  2.2.4
  2.2.5
  2.2.6
  2.2.7
  2.3.0-dev
  2.3.0-preview1
  2.3.0-preview2
  2.3.0
  2.3.1
  2.3.2
  2.3.3
  2.3.4
  2.4.0-dev
  2.4.0-preview1
  2.4.0-preview2
  2.4.0-preview3
  2.4.0-rc1
  2.4.0
  2.4.1
  2.5.0-dev
  jruby-1.5.6
  jruby-1.6.3
  jruby-1.6.4
  jruby-1.6.5
  jruby-1.6.5.1
  jruby-1.6.6
  jruby-1.6.7
  jruby-1.6.7.2
  jruby-1.6.8
  jruby-1.7.0-preview1
  jruby-1.7.0-preview2
  jruby-1.7.0-rc1
  jruby-1.7.0-rc2
  jruby-1.7.0
  jruby-1.7.1
  jruby-1.7.2
  jruby-1.7.3
  jruby-1.7.4
  jruby-1.7.5
  jruby-1.7.6
  jruby-1.7.7
  jruby-1.7.8
  jruby-1.7.9
  jruby-1.7.10
  jruby-1.7.11
  jruby-1.7.12
  jruby-1.7.13
  jruby-1.7.14
  jruby-1.7.15
  jruby-1.7.16
  jruby-1.7.16.1
  jruby-1.7.16.2
  jruby-1.7.17
  jruby-1.7.18
  jruby-1.7.19
  jruby-1.7.20
  jruby-1.7.20.1
  jruby-1.7.21
  jruby-1.7.22
  jruby-1.7.23
  jruby-1.7.24
  jruby-1.7.25
  jruby-1.7.26
  jruby-9.0.0.0.pre1
  jruby-9.0.0.0.pre2
  jruby-9.0.0.0.rc1
  jruby-9.0.0.0.rc2
  jruby-9.0.0.0
  jruby-9.0.1.0
  jruby-9.0.3.0
  jruby-9.0.4.0
  jruby-9.0.5.0
  jruby-9.1.0.0-dev
  jruby-9.1.0.0
  jruby-9.1.1.0
  jruby-9.1.2.0
  jruby-9.1.3.0
  jruby-9.1.4.0
  jruby-9.1.5.0
  jruby-9.1.6.0
  jruby-9.1.7.0
  jruby-9.1.8.0
  jruby-9.1.9.0-dev
  maglev-1.0.0
  maglev-1.1.0-dev
  maglev-2.0.0-dev
  mruby-dev
  mruby-1.0.0
  mruby-1.1.0
  mruby-1.2.0
  rbx-2.2.2
  rbx-2.2.3
  rbx-2.2.4
  rbx-2.2.5
  rbx-2.2.6
  rbx-2.2.7
  rbx-2.2.8
  rbx-2.2.9
  rbx-2.2.10
  rbx-2.3.0
  rbx-2.4.0
  rbx-2.4.1
  rbx-2.5.0
  rbx-2.5.1
  rbx-2.5.2
  rbx-2.5.3
  rbx-2.5.4
  rbx-2.5.5
  rbx-2.5.6
  rbx-2.5.7
  rbx-2.5.8
  rbx-2.6
  rbx-2.7
  rbx-2.8
  rbx-2.9
  rbx-2.10
  rbx-2.11
  rbx-2.71828182
  rbx-3.0
  rbx-3.1
  rbx-3.2
  rbx-3.3
  rbx-3.4
  rbx-3.5
  rbx-3.6
  rbx-3.7
  rbx-3.8
  rbx-3.9
  rbx-3.10
  rbx-3.11
  rbx-3.12
  rbx-3.13
  rbx-3.14
  rbx-3.15
  rbx-3.16
  rbx-3.17
  rbx-3.18
  rbx-3.19
  rbx-3.20
  rbx-3.21
  rbx-3.22
  rbx-3.23
  rbx-3.24
  rbx-3.25
  rbx-3.26
  rbx-3.27
  rbx-3.28
  rbx-3.29
  rbx-3.30
  rbx-3.31
  rbx-3.32
  rbx-3.33
  rbx-3.34
  rbx-3.35
  rbx-3.36
  rbx-3.37
  rbx-3.38
  rbx-3.39
  rbx-3.40
  rbx-3.41
  rbx-3.42
  rbx-3.43
  rbx-3.44
  rbx-3.45
  rbx-3.46
  rbx-3.47
  rbx-3.48
  rbx-3.49
  rbx-3.50
  rbx-3.51
  rbx-3.52
  rbx-3.53
  rbx-3.54
  rbx-3.55
  rbx-3.56
  rbx-3.57
  rbx-3.58
  rbx-3.59
  rbx-3.60
  rbx-3.61
  rbx-3.62
  rbx-3.63
  rbx-3.64
  rbx-3.65
  rbx-3.66
  rbx-3.67
  rbx-3.68
  rbx-3.69
  rbx-3.70
  rbx-3.71
  rbx-3.72
  ree-1.8.7-2011.03
  ree-1.8.7-2011.12
  ree-1.8.7-2012.01
  ree-1.8.7-2012.02
  topaz-dev
```
# Install Ruby with rbenv
###1.Install ruby (In this time, Version 2.4.1 (latest in 2017/4/20)
```
186590cdc78d:~ user$ rbenv install 2.4.1
ruby-build: use openssl from homebrew
Downloading ruby-2.4.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.1.tar.bz2
Installing ruby-2.4.1...
Installed ruby-2.4.1 to /Users/tomtan/.rbenv/versions/2.4.1
```
###2. Check ruby version which is able to be set 
```
186590cdc78d:~ user$ rbenv versions
* system (set by /Users/tomtan/.rbenv/version)
  2.4.1
```
###3. Change to latest version (2.0.0p648 is default in macOS)
```
186590cdc78d:~ user$ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
186590cdc78d:~ user$ rbenv global 2.4.1
186590cdc78d:~ user$ ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
```