Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

rbenvで2.4.1をインストールする手順

More than 3 years have passed since last update.

rbenvでruby2.4.1をインストールするときにちょっと手間取ったのでそのメモ。

作業環境

Mac OS X 10.11.6
ruby2.1.2 -> 2.4.1にします。

$ rbenv version
2.1.2

rbenvでインストール

$ rbenv install 2.4.1
ruby-build: definition not found: 2.4.1

The following versions contain `2.4.1' in the name:
  rbx-2.4.1

See all available versions with `rbenv install --list'.

If the version you need is missing, try upgrading ruby-build:

  brew update && brew upgrade ruby-build

なんか怒られたので確認。。

$ rbenv install --list

するとたしかにバージョン2.4系が一覧にはなかった。

homebrewのアップデート

ということで、rbenvをアップデートすべく、まずはhomebrewをアップデートしよう。

$ brew update
/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory
...
Error: update-report should not be called directly!

なんか怒られた。。

$ brew prune
Pruned 0 symbolic links and 2 directories from /usr/local
$ brew update

お、うまくいった。

rbenvのアップデート

$ 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...
ruby-build: use readline from homebrew

BUILD FAILED (OS X 10.11.6 using ruby-build 20170201)

Inspect or clean up the working tree at /var/folders/mt/q37kjktd79bd6315fwfqjj700000gn/T/ruby-build.20170328134756.36364
Results logged to /var/folders/mt/q37kjktd79bd6315fwfqjj700000gn/T/ruby-build.20170328134756.36364.log

Last 10 log lines:
make: *** Waiting for unfinished jobs....
dyld: lazy symbol binding failed: Symbol not found: _clock_gettime
  Referenced from: /private/var/folders/mt/q37kjktd79bd6315fwfqjj700000gn/T/ruby-build.20170328134756.36364/ruby-2.4.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/mt/q37kjktd79bd6315fwfqjj700000gn/T/ruby-build.20170328134756.36364/ruby-2.4.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

なんか怒られた。。
バージョンが古いっぽいのでxcode-selectで再インストール。

$ xcode-select --install
xcode-select: note: install requested for command line developer tools

もっかいチャレンジ!

$ 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...
ruby-build: use readline from homebrew
Installed ruby-2.4.1 to /Users/nishihara/.rbenv/versions/2.4.1

インストールできた!

あとはrbenvでrubyバージョンを指定すればOK。

$ rbenv global 2.4.1

以上。

参考

paranishian
フリーランスのエンジニアです。がんばってます。
https://paranishian.hateblo.jp/
admin-guild
「Webサービスの運営に必要なあらゆる知見」を共有できる場として作られた、運営者のためのコミュニティです。
https://admin-guild.slack.com
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