Let’s follow instructions for Ruby on Rails (except for the actual Ruby on Rails).
TLDR;
brew install rbenv ruby-build
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile
sudo xcode-select --install
rbenv install 2.3.1
rbenv global 2.3.1
ruby -v
Whole log, including failures:
~$ brew install rbenv ruby-build
==> Installing dependencies for rbenv: autoconf, ruby-build
==> Installing rbenv dependency: autoconf
==> Downloading https://homebrew.bintray.com/bottles/autoconf-2.69.el_capitan.bottle.4.tar.gz
######################################################################## 100,0%
==> Pouring autoconf-2.69.el_capitan.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.0M
==> Installing rbenv dependency: ruby-build
==> Downloading https://github.com/rbenv/ruby-build/archive/v20160602.tar.gz
==> Downloading from https://codeload.github.com/rbenv/ruby-build/tar.gz/v20160602
######################################################################## 100,0%
==> ./install.sh
🍺 /usr/local/Cellar/ruby-build/20160602: 282 files, 155.5K, built in 3 seconds
==> Installing rbenv
==> Downloading https://homebrew.bintray.com/bottles/rbenv-1.0.0.el_capitan.bottle.tar.gz
######################################################################## 100,0%
==> Pouring rbenv-1.0.0.el_capitan.bottle.tar.gz
==> 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
==> Summary
🍺 /usr/local/Cellar/rbenv/1.0.0: 36 files, 61.9K
~$ brew install rbenv ruby-build
~$ echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
~$ source ~/.bash_profile
~$ rbenv install 2.3.1
Downloading ruby-2.3.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.bz2
Installing ruby-2.3.1...
BUILD FAILED (OS X 10.11.6 using ruby-build 20160602)
Inspect or clean up the working tree at /var/folders/2s/2nmp6wjd4p12dhp8b74k7kzw0000gn/T/ruby-build.20160925182307.7454
Results logged to /var/folders/2s/2nmp6wjd4p12dhp8b74k7kzw0000gn/T/ruby-build.20160925182307.7454.log
Last 10 log lines:
Referenced from: /private/var/folders/2s/2nmp6wjd4p12dhp8b74k7kzw0000gn/T/ruby-build.20160925182307.7454/ruby-2.3.1/./miniruby (which was built for Mac OS X 10.12)
Expected in: /usr/lib/libSystem.B.dylib
dyld: Symbol not found: _clock_gettime
Referenced from: /private/var/folders/2s/2nmp6wjd4p12dhp8b74k7kzw0000gn/T/ruby-build.20160925182307.7454/ruby-2.3.1/./miniruby (which was built for Mac OS X 10.12)
Expected in: /usr/lib/libSystem.B.dylib
make: *** [.rbconfig.time] Trace/BPT trap: 5
make: *** Waiting for unfinished jobs....
make: *** [encdb.h] Trace/BPT trap: 5
~$ sudo xcode-select --install
Password:
xcode-select: note: install requested for command line developer tools
~$ rbenv install 2.3.1
Downloading ruby-2.3.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.bz2
Installing ruby-2.3.1...
Installed ruby-2.3.1 to /Users/novotnyr/.rbenv/versions/2.3.1
~$ rbenv global 2.3.1 -v
~$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
~$