Skip to content

Instantly share code, notes, and snippets.

@r7kamura
Last active November 15, 2020 15:31
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save r7kamura/4386574 to your computer and use it in GitHub Desktop.
Save r7kamura/4386574 to your computer and use it in GitHub Desktop.

Install rbenv on Mac OS X

homebrewで依存ライブラリを入れた後、homebrewでrbenvとruby-buildを入れる。

Requirements

rbenvとruby-buildを入れるために、以下のライブラリが必要。 過去に既に古いバージョンのものが入っていた場合は、brew linkしたり、brew link --forceする必要があるかもしれない。 自分の場合は、opensslとreadlineがそうだった。

  • libyaml
  • openssl
  • readline
  • autoconf
brew install libyaml openssl readline autoconf
brew link openssl
brew link -f readline

Install

rbenvとruby-buildを入れる。 その後、shellの設定に eval "$(rbenv init -)" の行を追加する。

brew install rbenv ruby-build
echo 'eval "$(rbenv init -)"' >> ~/.zshrc

Install Ruby

rbenv install <ruby_version>で任意のバージョンのRubyを入れる。 環境変数CONFIGURE_OPTSで、インストール時に利用するライブラリのパスを指定できる。 homebrewで/usr/localに入れたreadlineやopensslを指定している。 Ruby2.0を入れる場合、最新のbundler 1.2.3では動作しないので、--preオプションを付けて1.3.0を入れる。

CONFIGURE_OPTS="--with-readline-dir=/usr/local --with-openssl-dir=/usr/local" \
  rbenv install 2.0.0-dev
gem install bundler --pre
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment