プロジェクト

全般

プロフィール

InstallRailsMac » 履歴 » バージョン 77

Yuumi Yoshida, 2015-07-01 08:54

1 73 Yuumi Yoshida
h1.  Ruby on Rails 開発環境の作り方(Mac OS X 10.10)
2 1 Yuumi Yoshida
3 77 Yuumi Yoshida
_2015/07/01更新_
4 1 Yuumi Yoshida
5 46 Yuumi Yoshida
h3. 1 .  Command Line Toolsのインストール
6 1 Yuumi Yoshida
7 47 Yuumi Yoshida
ターミナルで以下を実行
8
<pre>
9 74 Yuumi Yoshida
$ xcode-select --install
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 76 Yuumi Yoshida
ダイアログが表示されずに、ターミナルに以下の様に表示された場合は  Command Line Tools は既にインストールされています。
17 49 Yuumi Yoshida
18
<pre>
19 75 Yuumi Yoshida
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
20 49 Yuumi Yoshida
</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 67 Yuumi Yoshida
h3. 3. rbenv, Rubyのインストール
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 ruby-build
58
$ brew install rbenv
59
$ rbenv install -l
60 1 Yuumi Yoshida
Available versions:
61 47 Yuumi Yoshida
  1.8.6-p383
62
63
  ...
64
65 77 Yuumi Yoshida
   2.2.2     ←表示に2.2.0があることを確認する。
66 47 Yuumi Yoshida
67
   ...
68
69 1 Yuumi Yoshida
</pre>
70 61 Yuumi Yoshida
71 1 Yuumi Yoshida
* Rubyのインストール
72 61 Yuumi Yoshida
* *以下のコマンドは長いの注意して下さい*
73 38 Yuumi Yoshida
74 37 Yuumi Yoshida
<pre>
75 77 Yuumi Yoshida
$ rbenv install 2.2.2
76 55 Yuumi Yoshida
$ rbenv rehash
77 77 Yuumi Yoshida
$ rbenv global 2.2.2
78 27 Yuumi Yoshida
</pre>
79 1 Yuumi Yoshida
80 34 Yuumi Yoshida
* .bash_profile  を編集、以下を追加
81
82
<pre>
83 18 Yuumi Yoshida
export PATH="$HOME/.rbenv/bin:$PATH" 
84 1 Yuumi Yoshida
eval "$(rbenv init -)" 
85 34 Yuumi Yoshida
</pre>
86
87 29 Yuumi Yoshida
* Rubyの確認、ターミナルで以下を実行
88 30 Yuumi Yoshida
89 34 Yuumi Yoshida
<pre>
90 55 Yuumi Yoshida
$ source .bash_profile
91
$ ruby -v
92 77 Yuumi Yoshida
ruby 2.2.2 .... # ← 確認
93 1 Yuumi Yoshida
</pre>
94
95 37 Yuumi Yoshida
h3. 4 .Railsのインストール
96
97
ターミナルで以下を実行
98 32 Yuumi Yoshida
99 34 Yuumi Yoshida
* gemコマンドのアップデート
100 32 Yuumi Yoshida
101 34 Yuumi Yoshida
<pre>
102
$ gem update --system -N
103
</pre>
104
105 68 Yuumi Yoshida
@Latest version currently installed. Aborting.@ と表示された場合は、最新版がインストールされているので問題ありません。
106
107 34 Yuumi Yoshida
* インストール
108
109 55 Yuumi Yoshida
<pre>
110 1 Yuumi Yoshida
$ gem install bundler -N
111 72 Yuumi Yoshida
$ gem install rspec -N
112 55 Yuumi Yoshida
$ gem install rails  -N
113 1 Yuumi Yoshida
$ rbenv rehash
114 64 Yuumi Yoshida
</pre>
115 1 Yuumi Yoshida
116 51 Yuumi Yoshida
※ gemインスト−ルの後の *rbenv rehash*  を忘れずに
117
118 34 Yuumi Yoshida
* 確認
119
120
<pre>
121 55 Yuumi Yoshida
$  rails -v
122 77 Yuumi Yoshida
Rails 4.2.3   # ← 確認
123 34 Yuumi Yoshida
</pre>
124 53 Yuumi Yoshida
125 54 Yuumi Yoshida
h3. 5. 関連ライブラリーのインストール
126
127
Ruby on Railsでは初めてプロジェクトを作った際に関連するライブラリーがインストールされるので、一度ダミーのプロジェクトを作成します。
128
129
<pre>
130 55 Yuumi Yoshida
$ cd /tmp
131
$ rails new dummy
132 54 Yuumi Yoshida
      create  
133
      create  README.rdoc
134
      create  Rakefile
135
136
      ...
137
138
Your bundle is complete!
139
Use `bundle show [gemname]` to see where a bundled gem is installed.
140
</pre>
141
142
ダミーのプロジェクトは削除してかまいません。