InstallRailsMac » 履歴 » バージョン 60
Yuumi Yoshida, 2014-04-21 19:57
| 1 | 52 | Yuumi Yoshida | h1. Ruby on Rails 開発環境の作り方(Mac OS X 10.9) |
|---|---|---|---|
| 2 | 1 | Yuumi Yoshida | |
| 3 | 60 | Yuumi Yoshida | _2014/04/21更新_ |
| 4 | 1 | Yuumi Yoshida | |
| 5 | 46 | Yuumi Yoshida | h3. 1 . Command Line Toolsのインストール |
| 6 | 1 | Yuumi Yoshida | |
| 7 | 47 | Yuumi Yoshida | ターミナルで以下を実行 |
| 8 | <pre> |
||
| 9 | 55 | Yuumi Yoshida | $ gcc |
| 10 | 47 | Yuumi Yoshida | </pre> |
| 11 | 1 | Yuumi Yoshida | |
| 12 | 47 | Yuumi Yoshida | 以下のようなダイアログが表示されるので「インストール」をクリックするとダウンロード・インストールが開始します |
| 13 | 34 | Yuumi Yoshida | |
| 14 | 1 | Yuumi Yoshida | !commandlinetools1.png! |
| 15 | 49 | Yuumi Yoshida | |
| 16 | ダイアログが表示されずに、ターミナルに以下の様に表示された場合は gcc は既にインストールされています。 |
||
| 17 | |||
| 18 | <pre> |
||
| 19 | clang: error: no input files |
||
| 20 | </pre> |
||
| 21 | 47 | Yuumi Yoshida | |
| 22 | 34 | Yuumi Yoshida | h3. 2. homebrew(Unix系ツール)のインストール |
| 23 | 1 | Yuumi Yoshida | |
| 24 | 46 | Yuumi Yoshida | Hombrew ホームページ http://brew.sh/ |
| 25 | 1 | Yuumi Yoshida | |
| 26 | ターミナルで以下を実行 |
||
| 27 | |||
| 28 | <pre> |
||
| 29 | 55 | Yuumi Yoshida | $ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" |
| 30 | 46 | Yuumi Yoshida | |
| 31 | ... |
||
| 32 | |||
| 33 | 50 | Yuumi Yoshida | Press ENTER to continue or any other key to abort # ← enter(return)キーを押す |
| 34 | 46 | Yuumi Yoshida | |
| 35 | ... |
||
| 36 | |||
| 37 | 50 | Yuumi Yoshida | To proceed, enter your password, or type Ctrl-C to abort. |
| 38 | 46 | Yuumi Yoshida | |
| 39 | 50 | Yuumi Yoshida | Password: # ← ログインのパスワードを入力 |
| 40 | 46 | Yuumi Yoshida | |
| 41 | 55 | Yuumi Yoshida | $ brew doctor |
| 42 | 46 | Yuumi Yoshida | |
| 43 | Your system is ready to brew. |
||
| 44 | |||
| 45 | 34 | Yuumi Yoshida | </pre> |
| 46 | |||
| 47 | 56 | Yuumi Yoshida | h3. 3. rbenv, Ruby 2.1.1のインストール |
| 48 | 34 | Yuumi Yoshida | |
| 49 | 複数のバージョンのRubyを切り換えて使えるコマンドです https://github.com/sstephenson/rbenv/ |
||
| 50 | |||
| 51 | 37 | Yuumi Yoshida | ターミナルで以下を実行 |
| 52 | 1 | Yuumi Yoshida | |
| 53 | 37 | Yuumi Yoshida | * rbenv のインストール |
| 54 | 27 | Yuumi Yoshida | |
| 55 | 1 | Yuumi Yoshida | <pre> |
| 56 | 57 | Yuumi Yoshida | $ brew update |
| 57 | 55 | Yuumi Yoshida | $ brew install openssl |
| 58 | 1 | Yuumi Yoshida | $ brew install readline |
| 59 | 57 | Yuumi Yoshida | $ brew install libyaml |
| 60 | 55 | Yuumi Yoshida | $ brew install ruby-build |
| 61 | $ brew install rbenv |
||
| 62 | $ rbenv install -l |
||
| 63 | 47 | Yuumi Yoshida | Available versions: |
| 64 | 1.8.6-p383 |
||
| 65 | |||
| 66 | ... |
||
| 67 | |||
| 68 | 56 | Yuumi Yoshida | 2.1.1 ←表示に2.1.1があることを確認する。 |
| 69 | 47 | Yuumi Yoshida | |
| 70 | ... |
||
| 71 | |||
| 72 | 37 | Yuumi Yoshida | </pre> |
| 73 | 1 | Yuumi Yoshida | |
| 74 | |||
| 75 | * Rubyのインストール |
||
| 76 | 38 | Yuumi Yoshida | * *以下のコマンドは長いの注意して下さい* |
| 77 | 1 | Yuumi Yoshida | |
| 78 | 37 | Yuumi Yoshida | <pre> |
| 79 | 60 | Yuumi Yoshida | $ RUBY_CONFIGURE_OPTS="--with-readline-dir=$(brew --prefix readline) --with-openssl-dir=$(brew --prefix openssl) --with-yaml-dir=$(brew --prefix libyaml)" rbenv install 2.1.1 |
| 80 | 55 | Yuumi Yoshida | $ rbenv rehash |
| 81 | 56 | Yuumi Yoshida | $ rbenv global 2.1.1 |
| 82 | 27 | Yuumi Yoshida | </pre> |
| 83 | 34 | Yuumi Yoshida | |
| 84 | * .bash_profile を編集、以下を追加 |
||
| 85 | |||
| 86 | 18 | Yuumi Yoshida | <pre> |
| 87 | 34 | Yuumi Yoshida | export PATH="$HOME/.rbenv/bin:$PATH" |
| 88 | eval "$(rbenv init -)" |
||
| 89 | 1 | Yuumi Yoshida | </pre> |
| 90 | 29 | Yuumi Yoshida | |
| 91 | 34 | Yuumi Yoshida | * Rubyの確認、ターミナルで以下を実行 |
| 92 | 30 | Yuumi Yoshida | |
| 93 | 34 | Yuumi Yoshida | <pre> |
| 94 | 55 | Yuumi Yoshida | $ source .bash_profile |
| 95 | $ ruby -v |
||
| 96 | 56 | Yuumi Yoshida | ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0] # ← 確認 |
| 97 | 1 | Yuumi Yoshida | </pre> |
| 98 | |||
| 99 | 37 | Yuumi Yoshida | h3. 4 .Railsのインストール |
| 100 | |||
| 101 | ターミナルで以下を実行 |
||
| 102 | 32 | Yuumi Yoshida | |
| 103 | 34 | Yuumi Yoshida | * gemコマンドのアップデート |
| 104 | 32 | Yuumi Yoshida | |
| 105 | 34 | Yuumi Yoshida | <pre> |
| 106 | 55 | Yuumi Yoshida | $ gem update --system -N |
| 107 | 34 | Yuumi Yoshida | </pre> |
| 108 | |||
| 109 | * インストール |
||
| 110 | |||
| 111 | <pre> |
||
| 112 | 55 | Yuumi Yoshida | $ gem install bundler -N |
| 113 | $ gem install rspec -N |
||
| 114 | $ gem install rails -N |
||
| 115 | 1 | Yuumi Yoshida | </pre> |
| 116 | 34 | Yuumi Yoshida | |
| 117 | 51 | Yuumi Yoshida | ※ gemインスト−ルの後の *rbenv rehash* を忘れずに |
| 118 | |||
| 119 | 34 | Yuumi Yoshida | * 確認 |
| 120 | |||
| 121 | <pre> |
||
| 122 | 55 | Yuumi Yoshida | $ rails -v |
| 123 | 59 | Yuumi Yoshida | Rails 4.1.0 # ← 確認 |
| 124 | 34 | Yuumi Yoshida | </pre> |
| 125 | 53 | Yuumi Yoshida | |
| 126 | 54 | Yuumi Yoshida | h3. 5. 関連ライブラリーのインストール |
| 127 | |||
| 128 | Ruby on Railsでは初めてプロジェクトを作った際に関連するライブラリーがインストールされるので、一度ダミーのプロジェクトを作成します。 |
||
| 129 | |||
| 130 | <pre> |
||
| 131 | 55 | Yuumi Yoshida | $ cd /tmp |
| 132 | $ rails new dummy |
||
| 133 | 54 | Yuumi Yoshida | create |
| 134 | create README.rdoc |
||
| 135 | create Rakefile |
||
| 136 | |||
| 137 | ... |
||
| 138 | |||
| 139 | Your bundle is complete! |
||
| 140 | Use `bundle show [gemname]` to see where a bundled gem is installed. |
||
| 141 | </pre> |
||
| 142 | |||
| 143 | ダミーのプロジェクトは削除してかまいません。 |
||
| 144 | |||
| 145 | 53 | Yuumi Yoshida | h3. その他 |
| 146 | |||
| 147 | エディターは Sublime text (ホームページ http://www.sublimetext.com) がお勧めです。 |
||
| 148 | (ただし Sublime textはフリーソフトではありません、無期限で試用できますが気に入ったら購入をお勧めします) |
||
| 149 | |||
| 150 | Sublime text をインストールしたら、ターミナルで以下を実行しすると、ターミナルからSublime textを起動でき便利になります。 |
||
| 151 | |||
| 152 | <pre> |
||
| 153 | 55 | Yuumi Yoshida | $ ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl |
| 154 | 53 | Yuumi Yoshida | |
| 155 | subl . |
||
| 156 | </pre> |