Ruby インストール(mac)
Ruby インストール(mac)
Homebrewのインストール
Homebrew はインストールが済んでいる前提で説明します。 下記記事の Homebrew インストール説明部分を参照してください。 Javascript(Node.js) 開発環境の構築 - ifujimori’s blog
rbenv のインストール
brew install を使って rbenvをインストーする。
brew install rbenv ruby-build
~ $ brew install rbenv ruby-build -bash: rew: command not found ~ $ brew install rbenv ruby-build Updating Homebrew... ==> Auto-updated Homebrew! Updated 1 tap (homebrew/core). ==> Updated Formulae ammonite-repl gitlab-ci-multi-runner mcabber tin apktool groonga pgformatter vapoursynth caddy influxdb prometheus vim collectd kapacitor pushpin youtube-dl dnscrypt-proxy khal qbs extract_url libosmium stormpath-cli fzf link-grammar telegraf ==> Installing dependencies for rbenv: autoconf, pkg-config, openssl, ruby-build ==> Installing rbenv dependency: autoconf ==> Downloading https://homebrew.bintray.com/bottles/autoconf-2.69.sierra.bottle.4.tar.gz ######################################################################## 100.0% ==> Pouring autoconf-2.69.sierra.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: pkg-config ==> Downloading https://homebrew.bintray.com/bottles/pkg-config-0.29.1_2.sierra.bottle.tar.gz ######################################################################## 100.0% ==> Pouring pkg-config-0.29.1_2.sierra.bottle.tar.gz 🍺 /usr/local/Cellar/pkg-config/0.29.1_2: 10 files, 627.5K ==> Installing rbenv dependency: openssl ==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2j.sierra.bottle.tar.gz ######################################################################## 100.0% ==> Pouring openssl-1.0.2j.sierra.bottle.tar.gz ==> Using the sandbox ==> Caveats A CA file has been bootstrapped using certificates from the SystemRoots keychain. To add additional certificates (e.g. the certificates added in the System keychain), 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. 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 PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig ==> Summary 🍺 /usr/local/Cellar/openssl/1.0.2j: 1,695 files, 12M ==> Installing rbenv dependency: ruby-build ==> Downloading https://github.com/rbenv/ruby-build/archive/v20170112.tar.gz ==> Downloading from https://codeload.github.com/rbenv/ruby-build/tar.gz/v20170112 ######################################################################## 100.0% ==> ./install.sh 🍺 /usr/local/Cellar/ruby-build/20170112: 325 files, 174.5K, built in 6 seconds ==> Installing rbenv ==> Downloading https://homebrew.bintray.com/bottles/rbenv-1.1.0.sierra.bottle.tar.gz ######################################################################## 100.0% ==> Pouring rbenv-1.1.0.sierra.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.1.0: 36 files, 63.2K
rbenv が正しくインストールできたか、バージョンを確認
~ $ rbenv -v rbenv 1.1.0
インストール可能な ruby のバージョンの一覧を表示
rbenv install -l
バージョン 2.4.0 の ruby をインストール
rbenv install 2.4.0
~ $ rbenv install 2.4.0 ruby-build: use openssl from homebrew Downloading ruby-2.4.0.tar.bz2... -> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.0.tar.bz2 Installing ruby-2.4.0... Installed ruby-2.4.0 to /Users/fujimori/.rbenv/versions/2.4.0
インストールされたことを rbenv versions で確認
~ $ rbenv versions * system (set by /Users/fujimori/.rbenv/version) 2.4.0
PATH に下記ディレクトリを追加する(.bash_profile にて追加)
/Users/[ユーザー名]/.rbenv/shims
rbenv global にて ruby をインストールしたバージョンに切り替える
rbenv global 2.4.0
ruby のバージョンの確認
~ $ ruby -v ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]