Mac OSX に Rails4.0.0 をインストールする

Mac での開発環境構築を継続します。今日は、Rails をインストールします。

参考資料

以下の本を参考に作業を進めますが、Mac にインストール済の Ruby を使用することを前提として記載されているので、大量の Web サイトも参照してます。

HerokuではじめるRailsプログラミング入門

HerokuではじめるRailsプログラミング入門

環境を確認する

  インストールする環境 備考
プロセッサ 1.3 GHz Intel Core i5 「この Mac について」で確認
MacOS OS X 10.8.4(12E3067)
Ruby ruby 2.0.0-p247 http://d.hatena.ne.jp/january/20130726/1374841561
ライブラリ openssl, GNU readline, rbenv, ruby-build

インストールする

admin 権限で実行する。ホームディレクトリから実行する。


sudo gem install rails


28個の gem がインストールされた。Successfully installed rails-4.0.0 と出力されているし、成功しているように見える。
ただし、ドキュメントをパースするにあたって、文字コードのコンバートに失敗したというメッセージが大量に出力されている。文書のパースなので、放置しておいても大丈夫なのかな。


Fetching: i18n-0.6.4.gem (100%)
Successfully installed i18n-0.6.4
Fetching: multi_json-1.7.7.gem (100%)
Successfully installed multi_json-1.7.7
Fetching: tzinfo-0.3.37.gem (100%)
Successfully installed tzinfo-0.3.37
Fetching: atomic-1.1.10.gem (100%)
Building native extensions. This could take a while...
Successfully installed atomic-1.1.10
Fetching: thread_safe-0.1.2.gem (100%)
Successfully installed thread_safe-0.1.2
Fetching: activesupport-4.0.0.gem (100%)
Successfully installed activesupport-4.0.0
Fetching: builder-3.1.4.gem (100%)
Successfully installed builder-3.1.4
Fetching: rack-1.5.2.gem (100%)
Successfully installed rack-1.5.2
Fetching: rack-test-0.6.2.gem (100%)
Successfully installed rack-test-0.6.2
Fetching: erubis-2.7.0.gem (100%)
Successfully installed erubis-2.7.0
Fetching: actionpack-4.0.0.gem (100%)
Successfully installed actionpack-4.0.0
Fetching: activemodel-4.0.0.gem (100%)
Successfully installed activemodel-4.0.0
Fetching: arel-4.0.0.gem (100%)
Successfully installed arel-4.0.0
Fetching: activerecord-deprecated_finders-1.0.3.gem (100%)
Successfully installed activerecord-deprecated_finders-1.0.3
Fetching: activerecord-4.0.0.gem (100%)
Successfully installed activerecord-4.0.0
Fetching: mime-types-1.23.gem (100%)
Successfully installed mime-types-1.23
Fetching: polyglot-0.3.3.gem (100%)
Successfully installed polyglot-0.3.3
Fetching: treetop-1.4.14.gem (100%)
Successfully installed treetop-1.4.14
Fetching: mail-2.5.4.gem (100%)
Successfully installed mail-2.5.4
Fetching: actionmailer-4.0.0.gem (100%)
Successfully installed actionmailer-4.0.0
Fetching: thor-0.18.1.gem (100%)
Successfully installed thor-0.18.1
Fetching: railties-4.0.0.gem (100%)
Successfully installed railties-4.0.0
Fetching: bundler-1.3.5.gem (100%)
Successfully installed bundler-1.3.5
Fetching: hike-1.2.3.gem (100%)
Successfully installed hike-1.2.3
Fetching: tilt-1.4.1.gem (100%)
Successfully installed tilt-1.4.1
Fetching: sprockets-2.10.0.gem (100%)
Successfully installed sprockets-2.10.0
Fetching: sprockets-rails-2.0.0.gem (100%)
Successfully installed sprockets-rails-2.0.0
Fetching: rails-4.0.0.gem (100%)
Successfully installed rails-4.0.0
Parsing documentation for i18n-0.6.4
Installing ri documentation for i18n-0.6.4
Parsing documentation for multi_json-1.7.7
Installing ri documentation for multi_json-1.7.7
Parsing documentation for tzinfo-0.3.37
Installing ri documentation for tzinfo-0.3.37
Parsing documentation for atomic-1.1.10
unable to convert "\xCF" from ASCII-8BIT to UTF-8 for lib/atomic_reference.bundle, skipping
Installing ri documentation for atomic-1.1.10
Parsing documentation for thread_safe-0.1.2
Installing ri documentation for thread_safe-0.1.2
Parsing documentation for activesupport-4.0.0
unable to convert "\x80" from ASCII-8BIT to UTF-8 for lib/active_support/values/unicode_tables.dat, skipping
Installing ri documentation for activesupport-4.0.0
Parsing documentation for builder-3.1.4
/Users/reiko/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/rdoc/parser.rb:87: warning: Unsupported encoding : ignored
/Users/reiko/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/rdoc/parser.rb:87: warning: Unsupported encoding ignored
Installing ri documentation for builder-3.1.4
Parsing documentation for rack-1.5.2
Installing ri documentation for rack-1.5.2
Parsing documentation for rack-test-0.6.2
Installing ri documentation for rack-test-0.6.2
Parsing documentation for erubis-2.7.0
Installing ri documentation for erubis-2.7.0
Parsing documentation for actionpack-4.0.0
Installing ri documentation for actionpack-4.0.0
Parsing documentation for activemodel-4.0.0
Installing ri documentation for activemodel-4.0.0
Parsing documentation for arel-4.0.0
Installing ri documentation for arel-4.0.0
Parsing documentation for activerecord-deprecated_finders-1.0.3
Installing ri documentation for activerecord-deprecated_finders-1.0.3
Parsing documentation for activerecord-4.0.0
Installing ri documentation for activerecord-4.0.0
Parsing documentation for mime-types-1.23
Installing ri documentation for mime-types-1.23
Parsing documentation for polyglot-0.3.3
Installing ri documentation for polyglot-0.3.3
Parsing documentation for treetop-1.4.14
Installing ri documentation for treetop-1.4.14
Parsing documentation for mail-2.5.4
unable to convert "\x80" from ASCII-8BIT to UTF-8 for lib/mail/values/unicode_tables.dat, skipping
Installing ri documentation for mail-2.5.4
Parsing documentation for actionmailer-4.0.0
Installing ri documentation for actionmailer-4.0.0
Parsing documentation for thor-0.18.1
Installing ri documentation for thor-0.18.1
Parsing documentation for railties-4.0.0
Installing ri documentation for railties-4.0.0
Parsing documentation for bundler-1.3.5
Installing ri documentation for bundler-1.3.5
Parsing documentation for hike-1.2.3
Installing ri documentation for hike-1.2.3
Parsing documentation for tilt-1.4.1
Installing ri documentation for tilt-1.4.1
Parsing documentation for sprockets-2.10.0
Installing ri documentation for sprockets-2.10.0
Parsing documentation for sprockets-rails-2.0.0
Installing ri documentation for sprockets-rails-2.0.0
Parsing documentation for rails-4.0.0
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/belongs_to.png, skipping
unable to convert "\xF4" from ASCII-8BIT to UTF-8 for guides/assets/images/book_icon.gif, skipping
unable to convert "\x91" from ASCII-8BIT to UTF-8 for guides/assets/images/bullet.gif, skipping
unable to convert "\xF5" from ASCII-8BIT to UTF-8 for guides/assets/images/chapters_icon.gif, skipping
unable to convert "\xF5" from ASCII-8BIT to UTF-8 for guides/assets/images/check_bullet.gif, skipping
unable to convert "\xF4" from ASCII-8BIT to UTF-8 for guides/assets/images/credits_pic_blank.gif, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/csrf.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/edge_badge.png, skipping
unable to convert "\x9E" from ASCII-8BIT to UTF-8 for guides/assets/images/favicon.ico, skipping
unable to convert "\x80" from ASCII-8BIT to UTF-8 for guides/assets/images/feature_tile.gif, skipping
unable to convert "\x80" from ASCII-8BIT to UTF-8 for guides/assets/images/footer_tile.gif, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/fxn.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/challenge.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/confirm_dialog.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/forbidden_attributes_for_new_post.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/form_with_errors.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/index_action_with_edit_link.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/new_post.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/post_with_comments.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/rails_welcome.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/routing_error_no_controller.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/routing_error_no_route_matches.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/show_action_for_posts.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/template_is_missing_posts_new.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/undefined_method_post_path.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/unknown_action_create_for_posts.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/getting_started/unknown_action_new_for_posts.png, skipping
unable to convert "\xF0" from ASCII-8BIT to UTF-8 for guides/assets/images/grey_bullet.gif, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/habtm.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/has_many.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/has_many_through.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/has_one.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/has_one_through.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/header_backdrop.png, skipping
unable to convert "\x80" from ASCII-8BIT to UTF-8 for guides/assets/images/header_tile.gif, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/i18n/demo_html_safe.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/i18n/demo_localized_pirate.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/i18n/demo_translated_en.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/i18n/demo_translated_pirate.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/i18n/demo_translation_missing.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/i18n/demo_untranslated.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/1.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/10.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/11.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/12.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/13.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/14.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/15.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/2.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/3.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/4.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/5.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/6.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/7.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/8.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/callouts/9.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/caution.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/example.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/home.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/important.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/next.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/note.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/prev.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/tip.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/up.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/icons/warning.png, skipping
unable to convert "\xFF" from ASCII-8BIT to UTF-8 for guides/assets/images/jaimeiniesta.jpg, skipping
unable to convert "\xF5" from ASCII-8BIT to UTF-8 for guides/assets/images/nav_arrow.gif, skipping
unable to convert "\xFF" from ASCII-8BIT to UTF-8 for guides/assets/images/oscardelben.jpg, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/polymorphic.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/radar.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/rails4_features.png, skipping
unable to convert "\xFF" from ASCII-8BIT to UTF-8 for guides/assets/images/rails_guides_kindle_cover.jpg, skipping
unable to convert "\xEC" from ASCII-8BIT to UTF-8 for guides/assets/images/rails_guides_logo.gif, skipping
unable to convert "\x8C" from ASCII-8BIT to UTF-8 for guides/assets/images/rails_logo_remix.gif, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/session_fixation.png, skipping
unable to convert "\x80" from ASCII-8BIT to UTF-8 for guides/assets/images/tab_grey.gif, skipping
unable to convert "\x80" from ASCII-8BIT to UTF-8 for guides/assets/images/tab_info.gif, skipping
unable to convert "\x80" from ASCII-8BIT to UTF-8 for guides/assets/images/tab_note.gif, skipping
unable to convert "\x80" from ASCII-8BIT to UTF-8 for guides/assets/images/tab_red.gif, skipping
unable to convert "\x80" from ASCII-8BIT to UTF-8 for guides/assets/images/tab_yellow.gif, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/tab_yellow.png, skipping
unable to convert "\xFF" from ASCII-8BIT to UTF-8 for guides/assets/images/vijaydev.jpg, skipping
Installing ri documentation for rails-4.0.0
28 gems installed

インストールの確認

Rails 4.0.0 がインストールされた。


$ rails -v
Rails 4.0.0

トラブルシューティング

実は、上記までにインストールに数回失敗して試行錯誤しているので、失敗と試行錯誤の経過を記録する。


$ rails -v
Rails is not currently installed on this system. To get the latest version, simply type:

$ sudo gem install rails

You can then rerun your "rails" command.

  1. ドキュメントのパースエラーが影響しているのか => 関係なさそう
  2. ruby と gem のバージョンがミスマッチなんじゃないの? => ★ビンゴだったが、見逃した★
    • macos - Install rails on Mac OS X - Super User」では、正しい gem 使われているの?という回答があったが、最終的には、バージョン番号 2.0.0p247 がタイポだということで収拾している。ruby -v の結果のことだと思うけど、どこで指定するのかとか迷走を始める。
  3. gem のバージョンの問題? => 関係あったかも
  4. 必要なライブラリがない? => 直接は関係なさそう
    • bundler とかインストールしてみる。$ sudo gem install bundler 。
  5. gem のパスの問題? => ★正解★


以上。