Macbook(Early 2008)にRuby 1.9.3とRuby on Rails 3.2をインストールする
最近は、Mac miniとばかりたわむれていたのでMacbookでの備忘録です。
Macbook(Early 2008)(Lion化済)で最新の Ruby 1.9.3 と Ruby on Rails 3.2 のインストールしました。
なお、RubyのインストールにHomebrewとrbenvを利用します。
大きな流れは以下のような感じです、
- rbenvとruby-buildのインストール
- readlineのインストール
- opensslのインストール
- rubyのインストール
- Ruby on Railsのインストール
rbenvとruby-buildのインストール
MacBook:~ log4jk$ brew install rbenv ==> Downloading https://github.com/sstephenson/rbenv/tarball/v0.3.0 ######################################################################## 100.0% ==> Caveats To enable shims and autocompletion, add rbenv init to your profile: if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi ==> Summary /usr/local/Cellar/rbenv/0.3.0: 32 files, 160K, built in 9 seconds MacBook:~ log4jk$ brew install ruby-build ==> Downloading https://github.com/sstephenson/ruby-build/tarball/v20120815 ######################################################################## 100.0% ==> ./install.sh /usr/local/Cellar/ruby-build/20120815: 49 files, 212K, built in 7 seconds MacBook:~ log4jk$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile MacBook:~ log4jk$ source ~/.bash_profile
readlineのインストール
MacBook:~ log4jk$ brew install readline ==> Downloading http://ftpmirror.gnu.org/readline/readline-6.2.tar.gz ######################################################################## 100.0% ==> Patching patching file callback.c patching file input.c patching file patchlevel patching file support/shobj-conf patching file vi_mode.c ==> ./configure --prefix=/usr/local/Cellar/readline/6.2.4 --mandir=/usr/local/Cellar/readline/6.2.4/share/man --infodir=/usr/local/Cellar/readline/6.2.4/share/info --enable-multibyte ==> make install ==> Caveats This 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 are defaulting this GNU Readline installation to keg-only. 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/readline/lib CPPFLAGS: -I/usr/local/opt/readline/include ==> Summary /usr/local/Cellar/readline/6.2.4: 30 files, 1.6M, built in 38 seconds MacBook:~ log4jk$ brew link readline Linking /usr/local/Cellar/readline/6.2.4... 12 symlinks created
opensslのインストール
MacBook:~ log4jk$ brew install openssl ==> Downloading http://openssl.org/source/openssl-1.0.1c.tar.gz ######################################################################## 100.0% ==> perl ./Configure --prefix=/usr/local/Cellar/openssl/1.0.1c --openssldir=/usr/local/etc/openssl zlib-dynamic shared darwin64-x86_64-cc ==> make ==> make test ==> make install MANDIR=/usr/local/Cellar/openssl/1.0.1c/share/man MANSUFFIX=ssl ==> Caveats This formula is keg-only: so 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. The OpenSSL provided by OS X is too old for some software. 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.1c: 428 files, 15M, built in 5.3 minutes MacBook:~ log4jk$ brew link openssl Linking /usr/local/Cellar/openssl/1.0.1c... 1139 symlinks created
rubyのインストール
以下のページよりrubyの最新版を確認します。(2013/01/04時点では、1.9.3-p362でした)
http://www.ruby-lang.org/ja/downloads/
と思ったら、rbenvのruby-buildで蹴られました。ruby-buildのバージョンが古く、該当のバージョンが含まれていないようです。ruby-buildをgitリポジトリより最新版を取得し、入れ直します。と思いましたが、homebrewでアップグレードさせれば最新版になりました。
MacBook:~ log4jk$ CONFIGURE_OPTS="--with-readline-dir=/usr/local --with-openssl-dir=/usr/local" rbenv install 1.9.3-p362 ruby-build: definition not found: 1.9.3-p362 MacBook:~ log4jk$ ruby-build -v ruby-build 20120815 usage: ruby-build [-k|--keep] [-v|--verbose] definition prefix ruby-build --definitions MacBook:~ log4jk$ ruby-build --definitions | grep 1.9 1.9.1-p378 1.9.2-p180 1.9.2-p290 1.9.2-p318 1.9.2-p320 1.9.3-dev 1.9.3-p0 1.9.3-p125 1.9.3-p194 1.9.3-preview1 1.9.3-rc1 MacBook:~ log4jk$ brew upgrade --HEAD ruby-build ==> Upgrading ruby-build ==> Cloning https://github.com/sstephenson/ruby-build.git Cloning into '/Library/Caches/Homebrew/ruby-build--git'… remote: Counting objects: 90, done. remote: Compressing objects: 100% (71/71), done. remote: Total 90 (delta 33), reused 36 (delta 13) Unpacking objects: 100% (90/90), done. ==> ./install.sh /usr/local/Cellar/ruby-build/HEAD: 62 files, 268K, built in 7 seconds MacBook:~ log4jk$ ruby-build -v ruby-build 20121227 usage: ruby-build [-k|--keep] [-v|--verbose] definition prefix ruby-build --definitions MacBook:~ log4jk$ ruby-build --definitions | grep 1.9 1.9.1-p378 1.9.2-p180 1.9.2-p290 1.9.2-p318 1.9.2-p320 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-preview1 1.9.3-rc1 MacBook:~ log4jk$ MacBook:~ log4jk$ CONFIGURE_OPTS="--with-readline-dir=/usr/local --with-openssl-dir=/usr/local" rbenv install 1.9.3-p362 Downloading yaml-0.1.4.tar.gz… -> http://dqw8nmjcqpjn7.cloudfront.net/36c852831d02cf90508c29852361d01b Installing yaml-0.1.4… Installed yaml-0.1.4 to /Users/log4jk/.rbenv/versions/1.9.3-p362 Downloading ruby-1.9.3-p362.tar.gz… -> http://dqw8nmjcqpjn7.cloudfront.net/1efc2316dc50e97591792d90647fade2 Installing ruby-1.9.3-p362… Installed ruby-1.9.3-p362 to /Users/log4jk/.rbenv/versions/1.9.3-p362 MacBook:~ log4jk$ rbenv rehash MacBook:~ log4jk$ rbenv global 1.9.3-p194 rbenv: version `1.9.3-p194' not installed MacBook:~ log4jk$ rbenv global 1.9.3-p362 MacBook:~ log4jk$ rbenv version 1.9.3-p362 (set by /Users/log4jk/.rbenv/version) MacBook:~ log4jk$ ruby -v ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-darwin11.4.2]
Ruby on Railsのインストール
MacBook:~ log4jk$ rbenv exec gem install rails --version="~> 3.2.8" Fetching: i18n-0.6.1.gem (100%) Fetching: multi_json-1.5.0.gem (100%) Fetching: activesupport-3.2.10.gem (100%) Fetching: builder-3.0.4.gem (100%) Fetching: activemodel-3.2.10.gem (100%) Fetching: rack-1.4.1.gem (100%) Fetching: rack-cache-1.2.gem (100%) Fetching: rack-test-0.6.2.gem (100%) Fetching: journey-1.0.4.gem (100%) Fetching: hike-1.2.1.gem (100%) Fetching: tilt-1.3.3.gem (100%) Fetching: sprockets-2.2.2.gem (100%) Fetching: erubis-2.7.0.gem (100%) Fetching: actionpack-3.2.10.gem (100%) Fetching: arel-3.0.2.gem (100%) Fetching: tzinfo-0.3.35.gem (100%) Fetching: activerecord-3.2.10.gem (100%) Fetching: activeresource-3.2.10.gem (100%) Fetching: mime-types-1.19.gem (100%) Fetching: polyglot-0.3.3.gem (100%) Fetching: treetop-1.4.12.gem (100%) Fetching: mail-2.4.4.gem (100%) Fetching: actionmailer-3.2.10.gem (100%) Fetching: rack-ssl-1.3.2.gem (100%) Fetching: thor-0.16.0.gem (100%) Fetching: railties-3.2.10.gem (100%) Fetching: bundler-1.2.3.gem (100%) Fetching: rails-3.2.10.gem (100%) Successfully installed i18n-0.6.1 Successfully installed multi_json-1.5.0 Successfully installed activesupport-3.2.10 Successfully installed builder-3.0.4 Successfully installed activemodel-3.2.10 Successfully installed rack-1.4.1 Successfully installed rack-cache-1.2 Successfully installed rack-test-0.6.2 Successfully installed journey-1.0.4 Successfully installed hike-1.2.1 Successfully installed tilt-1.3.3 Successfully installed sprockets-2.2.2 Successfully installed erubis-2.7.0 Successfully installed actionpack-3.2.10 Successfully installed arel-3.0.2 Successfully installed tzinfo-0.3.35 Successfully installed activerecord-3.2.10 Successfully installed activeresource-3.2.10 Successfully installed mime-types-1.19 Successfully installed polyglot-0.3.3 Successfully installed treetop-1.4.12 Successfully installed mail-2.4.4 Successfully installed actionmailer-3.2.10 Successfully installed rack-ssl-1.3.2 Successfully installed thor-0.16.0 Successfully installed railties-3.2.10 Successfully installed bundler-1.2.3 Successfully installed rails-3.2.10 28 gems installed MacBook:~ log4jk$ rbenv rehash MacBook:~ log4jk$ source .bash_profile MacBook:~ log4jk$ rails -v Rails 3.2.10
今度、Mac mini側も入れます。