Ruby
Mac
OSX
Xcode
rbenv

Xcode8環境下でrbenvにてrubyのコンパイルに失敗する

More than 1 year has passed since last update.

$ 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/w1/_jhh90bj5lx0xg0hycdqvjs40000gn/T/ruby-build.20160918151039.20332
Results logged to /var/folders/w1/_jhh90bj5lx0xg0hycdqvjs40000gn/T/ruby-build.20160918151039.20332.log

Last 10 log lines:
Referenced from: /private/var/folders/w1/_jhh90bj5lx0xg0hycdqvjs40000gn/T/ruby-build.20160918151039.20332/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/w1/_jhh90bj5lx0xg0hycdqvjs40000gn/T/ruby-build.20160918151039.20332/ruby-2.3.1/./miniruby (which was built for Mac OS X 10.12)
Expected in: /usr/lib/libSystem.B.dylib

make: *** [encdb.h] Trace/BPT trap: 5
make: *** Waiting for unfinished jobs....
make: *** [.rbconfig.time] Trace/BPT trap: 5

Mac OS X 10.12 用のが入っているのが原因なようなので、必要なツールをインストールする

$ xcode-select --install


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/xxxx/.rbenv/versions/2.3.1

と解決