LoginSignup
6
6

More than 5 years have passed since last update.

【Mac, Ruby】MacにrbenvでRubyをインストールする

Last updated at Posted at 2014-12-25

前提

  • OSX Yosemite 10.10.1で動作確認をしています
  • Homebrewがインストールされている前提です

rbenv公式サイト

http://rbenv.org/
https://github.com/sstephenson/rbenv

Homebrewでrbenvをインストール

rbenvをインストール

$ brew install rbenv
==> Downloading https://github.com/sstephenson/rbenv/archive/v0.4.0.tar.gz
######################################################################## 100.0%
==> Caveats
To use Homebrew's directories rather than ~/.rbenv add to your profile:
  export RBENV_ROOT=/usr/local/var/rbenv

To enable shims and autocompletion add to your profile:
  if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
==> Summary
?  /usr/local/Cellar/rbenv/0.4.0: 31 files, 152K, built in 4 seconds

ruby-buildをインストール

$ brew install ruby-build
==> Installing dependencies for ruby-build: autoconf, pkg-config, openssl
==> Installing ruby-build dependency: autoconf
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/autoconf-2.69.yosemite.    bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring autoconf-2.69.yosemite.bottle.1.tar.gz
?  /usr/local/Cellar/autoconf/2.69: 70 files, 3.1M
==> Installing ruby-build dependency: pkg-config
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/pkg-config-0.28.yosemite.  bottle.2.tar.gz
######################################################################## 100.0%
==> Pouring pkg-config-0.28.yosemite.bottle.2.tar.gz
?  /usr/local/Cellar/pkg-config/0.28: 10 files, 612K
==> Installing ruby-build dependency: openssl
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/openssl-1.0.1j_1.yosemite  .bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl-1.0.1j_1.yosemite.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local.

Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include

==> Summary
?  /usr/local/Cellar/openssl/1.0.1j_1: 431 files, 15M
==> Installing ruby-build
==> Downloading https://github.com/sstephenson/ruby-build/archive/v20141222.tar.gz
######################################################################## 100.0%
==> ./install.sh
?  /usr/local/Cellar/ruby-build/20141222: 142 files, 608K, built in 5 seconds

環境変数の設定

$ echo 'export PATH="$HOME/.rbenv/shims:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
$ source ~/.bash_profile

rbenvのインストールを確認

$ rbenv -v
rbenv 0.4.0

Rubyのインストール

インストールできるRubyのバージョンを確認

$ rbenv install -l   # インストールできるRubyのバージョンを確認

Rubyのインストール

$ rbenv install 2.0.0-p598

デフォルトで利用するバージョンを指定

$ rbenv global 2.0.0-p598

まとめ

MacOSにrbenvを利用してRubyをインストールする環境を構築しました。

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6