MacにRubyのrbenvを構築する
はじめに
こんにちは。インフラエンジニアレベル001のf_prgです。 Ruby徹底攻略 (WEB+DB PRESS plus) という本を購入して、Macにrbenvの環境を作りましたので、その際の実行ログです。
構築
インストール
[17:57:57][f_prg@mba:~]# brew install openssl libyaml readline gmp==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/openssl-1.0######################################################################### 100.0%==> Pouring openssl-1.0.1g.mavericks.bottle.tar.gz==> CaveatsA CA file has been bootstrapped using certificates from the systemkeychain. 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, so it was not symlinked into /usr/local.
Mac OS X already provides this software and installing another version inparallel can cause all kinds of trouble.
The OpenSSL provided by OS X is too old for some software.
Generally there are no consequences of this for you. If you build yourown software and it requires this formula, you'll need to add to yourbuild variables:
LDFLAGS: -L/usr/local/opt/openssl/lib CPPFLAGS: -I/usr/local/opt/openssl/include
==> Summary🍺 /usr/local/Cellar/openssl/1.0.1g: 429 files, 15MError: libyaml-0.1.5 already installedTo install this version, first `brew unlink libyaml'Warning: It appears you have MacPorts or Fink installed.Software installed with other package managers causes known problems forHomebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/readline-6.######################################################################### 100.0%==> Pouring readline-6.3.5.mavericks.bottle.tar.gz==> CaveatsThis formula is keg-only, so it was not symlinked into /usr/local.
OS X provides the BSD libedit library, which shadows libreadline.In order to prevent conflicts when programs look for libreadline we aredefaulting this GNU Readline installation to keg-only.
Generally there are no consequences of this for you. If you build yourown software and it requires this formula, you'll need to add to yourbuild variables:
LDFLAGS: -L/usr/local/opt/readline/lib CPPFLAGS: -I/usr/local/opt/readline/include
==> Summary🍺 /usr/local/Cellar/readline/6.3.5: 40 files, 2.1M==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/gmp-6.0.0a.######################################################################### 100.0%==> Pouring gmp-6.0.0a.mavericks.bottle.tar.gz🍺 /usr/local/Cellar/gmp/6.0.0a: 15 files, 3.2M[17:59:14][f_prg@mba:~]# git clone https://github.com/sstephenson/rbenv.git ~/.rbenvCloning into '/Users/f_prg/.rbenv'...remote: Counting objects: 1889, done.remote: Total 1889 (delta 0), reused 0 (delta 0)Receiving objects: 100% (1889/1889), 297.15 KiB | 216.00 KiB/s, done.Resolving deltas: 100% (1182/1182), done.Checking connectivity... done.[21:25:50][f_prg@mba:~]# git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-buildCloning into '/Users/f_prg/.rbenv/plugins/ruby-build'...remote: Counting objects: 3548, done.remote: Total 3548 (delta 0), reused 0 (delta 0)Receiving objects: 100% (3548/3548), 601.68 KiB | 331.00 KiB/s, done.Resolving deltas: 100% (1709/1709), done.Checking connectivity... done.[21:31:36][f_prg@mba:~]# echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile[21:31:59][f_prg@mba:~]# echo 'eval "$(rbenv init -)"' >> ~/.bash_profile[21:33:27][f_prg@mba:~]# source ~/.bash_profile[21:33:40][f_prg@mba:~]# rbenv install --listAvailable versions: 1.8.6-p383 1.8.6-p420 1.8.7-p249 1.8.7-p302 1.8.7-p334 1.8.7-p352 1.8.7-p357 1.8.7-p358 1.8.7-p370 1.8.7-p371 1.8.7-p374 1.8.7-p375 1.9.1-p378 1.9.1-p430 1.9.2-p0 1.9.2-p180 1.9.2-p290 1.9.2-p318 1.9.2-p320 1.9.2-p326 1.9.3-dev 1.9.3-p0 1.9.3-p125 1.9.3-p194 1.9.3-p286 1.9.3-p327 1.9.3-p362 1.9.3-p374 1.9.3-p385 1.9.3-p392 1.9.3-p429 1.9.3-p448 1.9.3-p484 1.9.3-p545 1.9.3-p547 1.9.3-preview1 1.9.3-rc1 2.0.0-dev 2.0.0-p0 2.0.0-p195 2.0.0-p247 2.0.0-p353 2.0.0-p451 2.0.0-p481 2.0.0-preview1 2.0.0-preview2 2.0.0-rc1 2.0.0-rc2 2.1.0 2.1.0-dev 2.1.0-preview1 2.1.0-preview2 2.1.0-rc1 2.1.1 2.1.2 2.2.0-dev jruby-1.5.6 jruby-1.6.3 jruby-1.6.4 jruby-1.6.5 jruby-1.6.5.1 jruby-1.6.6 jruby-1.6.7 jruby-1.6.7.2 jruby-1.6.8 jruby-1.7.0 jruby-1.7.0-preview1 jruby-1.7.0-preview2 jruby-1.7.0-rc1 jruby-1.7.0-rc2 jruby-1.7.1 jruby-1.7.10 jruby-1.7.11 jruby-1.7.12 jruby-1.7.13 jruby-1.7.2 jruby-1.7.3 jruby-1.7.4 jruby-1.7.5 jruby-1.7.6 jruby-1.7.7 jruby-1.7.8 jruby-1.7.9 jruby-9000+graal-dev jruby-9000-dev maglev-1.0.0 maglev-1.1.0-dev maglev-2.0.0-dev mruby-1.0.0 mruby-dev rbx-1.2.4 rbx-2.0.0 rbx-2.0.0-dev rbx-2.0.0-rc1 rbx-2.1.0 rbx-2.1.1 rbx-2.2.0 rbx-2.2.1 rbx-2.2.10 rbx-2.2.2 rbx-2.2.3 rbx-2.2.4 rbx-2.2.5 rbx-2.2.6 rbx-2.2.7 rbx-2.2.9 ree-1.8.6-2009.06 ree-1.8.7-2009.09 ree-1.8.7-2009.10 ree-1.8.7-2010.01 ree-1.8.7-2010.02 ree-1.8.7-2011.03 ree-1.8.7-2011.12 ree-1.8.7-2012.01 ree-1.8.7-2012.02 topaz-dev[21:39:38][f_prg@mba:~]# rbenv install 2.1.2Downloading ruby-2.1.2.tar.gz...-> http://dqw8nmjcqpjn7.cloudfront.net/f22a6447811a81f3c808d1c2a5ce3b5f5f0955c68c9a749182feb425589e6635Installing ruby-2.1.2...Installed ruby-2.1.2 to /Users/f_prg/.rbenv/versions/2.1.2
[22:01:48][f_prg@mba:~]# rbenv global 2.1.2[22:01:49][f_prg@mba:~]# rbenv rehash[22:01:58][f_prg@mba:~]# ruby -vruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]まとめ
簡単にできました。 今後、OS入れ替えた際にまた必要になりそうですね。 次回は、Centos版も業務でやったので投稿しようと思います。