Skip to content

Instantly share code, notes, and snippets.

@tomoyukiinoue
Created December 8, 2013 00:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomoyukiinoue/7851789 to your computer and use it in GitHub Desktop.
Save tomoyukiinoue/7851789 to your computer and use it in GitHub Desktop.
Mac OS X 10.9 のRails 4.0.0を4.0.2にアップデートしたときのメモ

Mac OS X 10.9 のRails 4.0.0を4.0.2にアップデートしたときのメモ

現在のバージョンをチェック

$ rails --version
Rails 4.0.0
$ rake --version
rake, version 10.1.0
$ gem --version
2.0.3
$ ruby --version
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
$ rbenv --version
rbenv 0.4.0
$ ruby-build --version
ruby-build 20130628

Homebrewをアップデート

しばらく Homebrewをアップデートしていなかったので、brew updateでアップデートしておきます。

$ brew update
Error: undefined method `to_sym' for nil:NilClass
Please report this bug:
    https://github.com/mxcl/homebrew/wiki/troubleshooting
/usr/local/Library/Homebrew/cmd/update.rb:103:in `report'
/usr/local/Library/Homebrew/cmd/update.rb:101:in `each_line'
/usr/local/Library/Homebrew/cmd/update.rb:101:in `report'
/usr/local/Library/Homebrew/cmd/update.rb:23:in `update'
/usr/local/Library/brew.rb:95:in `send'
/usr/local/Library/brew.rb:95

エラーで完了しないので brew doctor で原因を確認します。

$ brew doctor
Warning: /usr/local/share/python is not needed in PATH.
Formerly homebrew put Python scripts you installed via `pip` or `pip3`
(or `easy_install`) into that directory above but now it can be removed
from your PATH variable.
Python scripts will now install into /usr/local/bin.
You can delete anything, except 'Extras', from the /usr/local/share/python
(and /usr/local/share/python3) dir and install affected Python packages
anew with `pip install --upgrade`.

Warning: No developer tools installed.
You should install the Command Line Tools.
Run `xcode-select --install` to install them.

運良くコマンドラインツールが入っていないことが原因と分かりました。アドバイス通りに xcode-select --install を実行します。

$ xcode-select --install
xcode-select: note: install requested for command line developer tools

コマンドラインツールをインストールするGUIが起動します。指示に従ってインストールします。

インストールが完了したら、再度、brew updateを実行します。

$ brew update
Already up-to-date.

最新の状態なら上記の表示、そうでなければ Homebrew がアップデートされます。

ruby-buildをアップデート

ruby-buildをアップデートします。

$ brew upgrade ruby-build
==> Upgrading 1 outdated package, with result:
ruby-build 20131206
==> Upgrading ruby-build
==> Installing ruby-build dependency: libyaml
==> Downloading http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/libyaml/0.1.4
==> make install
🍺  /usr/local/Cellar/libyaml/0.1.4: 7 files, 344K, built in 31 seconds
==> Installing ruby-build
==> Downloading https://github.com/sstephenson/ruby-build/archive/v20131206.tar.gz
######################################################################## 100.0%
==> ./install.sh
🍺  /usr/local/Cellar/ruby-build/20131206: 98 files, 432K, built in 6 seconds

アップデートされているか確認します。2.0.0-p353があればOK(2013/12/08現在)。

$ ruby-build --version
ruby-build 20131206
$ rbenv install --list | grep -e "  2"
  2.0.0-dev
  2.0.0-p0
  2.0.0-p195
  2.0.0-p247
  2.0.0-p353
  2.0.0-preview1
  2.0.0-preview2
  2.0.0-rc1
  2.0.0-rc2
  2.1.0-dev
  2.1.0-preview1
  2.1.0-preview2

Ruby をアップデート

rbenv で2.0.0-p353をインストールします。少し時間がかかりますので気長に待ちましょう。

$ rbenv install 2.0.0-p353
Downloading openssl-1.0.1e.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/66bf6f10f060d561929de96f9dfe5b8c
Installing openssl-1.0.1e...
Installed openssl-1.0.1e to /Users/inoue/.rbenv/versions/2.0.0-p353

Downloading ruby-2.0.0-p353.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/78282433fb697dd3613613ff55d734c1
Installing ruby-2.0.0-p353...
Installed ruby-2.0.0-p353 to /Users/inoue/.rbenv/versions/2.0.0-p353

rbenv で ruby のバージョンを切り替えます。

$ rbenv global 2.0.0-p353
~ $ ruby --version
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin13.0.0]

Rake をアップデート

Ruby アップデート直後に、0.9.6 にバージョンダウンしてしまいました。Rails 4 では、いろいろ不都合を起こすので Rake を 10.x 系の最新にアップデートします。

$ gem --version
2.0.14
$ rake --version
rake, version 0.9.6

gem update で RubyGemsをアップデートします。途中、Rake、Rdoc, ri を上書きするか聞かれるので y で進めます。

$ gem update
(中略)
Updating rake
Fetching: rake-10.1.0.gem (100%)
rake's executable "rake" conflicts with /Users/inoue/.rbenv/versions/2.0.0-p353/bin/rake
Overwrite the executable? [yN]  y
(中略)
Updating rdoc
Fetching: rdoc-4.0.1.gem (100%)
rdoc's executable "rdoc" conflicts with /Users/inoue/.rbenv/versions/2.0.0-p353/bin/rdoc
Overwrite the executable? [yN]  y
rdoc's executable "ri" conflicts with /Users/inoue/.rbenv/versions/2.0.0-p353/bin/ri
Overwrite the executable? [yN]  y
(中略)

Rakeが10.1.0にアップデートされます。

$ rake --version
rake, version 10.1.0

Rails をアップデート

RubyGems で Rails をアップデートします。

$ gem install rails --no-ri --no-rdoc
(中略)
Fetching: rails-4.0.2.gem (100%)
Successfully installed rails-4.0.2
28 gems installed

Rails が 4.0.2 にアップデートされました。

$ rails --version
Rails 4.0.2

Rails の動作確認

$ rails new blog && cd blog
      create  
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
(中略)

$ rails s
=> Booting WEBrick
=> Rails 4.0.2 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2013-12-08 09:24:44] INFO  WEBrick 1.3.1
[2013-12-08 09:24:44] INFO  ruby 2.0.0 (2013-11-22) [x86_64-darwin13.0.0]
[2013-12-08 09:24:44] INFO  WEBrick::HTTPServer#start: pid=87119 port=3000

適当なブラウザで http//localhost:3000 にアクセスしていつもの画面が出てくれば完了です。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment