"Diary" インターネットさんへの恩返し

いつもソースコードコピペばかりなので,みなさまへ少しばかりの恩返しを

Ruby on Rails インストールメモ



スポンサーリンク

■On Windows

★以下うまくいったパターン

1.http://rubyonrails.org/download からRuby 1.9.3 のinstaller(exe)をダウンロードしダブルクリックでインストール。

2.プログラムから「Rubyコマンドプロンプトを開く」

3.gem install railsを実行

★以下ダメだったパターン

1.媒体のダウンロード(instant Rails2.0

2.任意のフォルダ(スペースを含まない)にダウンロードファイル解凍
→インストールディレクトリとなる

3.InstantRails.exeの実行

4.設定ファイルの再作成プロンプトがでるので「OK」をクリック

5.コンソールが起動するので [i] > [Rails Application] > [Open Ruby Console Window] を開く

6.アップデート
上手くいかない。ググるとGEMのURLが古いらしい。GEMのアップデートをしてみる

C:\Rails\rails_apps>gem update --system
Updating RubyGems...
ERROR:  While executing gem ... (Gem::RemoteSourceException)
    HTTP Response 302 fetching http://gems.rubyforge.org/yaml

C:\Rails\rails_apps>gem update --system
Updating RubyGems...
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    接続済みの呼び出し先が一定の時間を過ぎても正しく応答しなかったため、接続でき
ませんでした。または接続済みのホストが応答しなかったため、確立された接続は失敗し
ました。 - connect(2) (Errno::ETIMEDOUT)
        getting size of http://gems.rubyforge.org/Marshal.4.8

gem update --system でも上手くいかない場合は、 gem install rubygems-updateで行くこともあるらしいがこれもダメ。

rubygems-1.8.25.zipをダウンロードしてきて以下を実行したがなんかうまくいっていない。Gemの更新前の前提がRuby1.8.7じゃないとだめなのかな。そういえばruby1.8.6だ。

C:\Rails\rubygems-1.8.25>cd C:\Rails\rubygems-1.8.25

C:\Rails\rubygems-1.8.25>ruby setup.rb
./lib/rubygems.rb:335: warning: parenthesize argument(s) for future version
./lib/rubygems.rb:517: warning: parenthesize argument(s) for future version
./lib/rubygems.rb:32:in `require': ./lib/rubygems/deprecate.rb:54: syntax error,
 unexpected ',', expecting '|' (SyntaxError)
        define_method name do |*args, &block| # TODO: really works on 1.8.7?
                                     ^
./lib/rubygems/deprecate.rb:55: syntax error, unexpected tCONSTANT, expecting '}
'
./lib/rubygems/deprecate.rb:64: syntax error, unexpected kEND, expecting '}'
./lib/rubygems/deprecate.rb:69: syntax error, unexpected kEND, expecting '}'
from ./lib/rubygems.rb:32
        from setup.rb:27:in `require'
        from setup.rb:27

結局、rubygems-1.4.2をダウンロードし実行したところ上手くいった。

C:\Rails\rubygems-1.4.2>ruby setup.rb
RubyGems 1.4.2 installed
File not found: README


7.GEMバージョン確認
更新前は1.0.1だった。

C:\Rails\rubygems-1.4.2>gem -v
1.4.2

8.もう一度Gemの更新

# gem update --system

 ・
 ・
 ・
 ・

As of RubyGems 0.8.0, library stubs are no longer needed.
Searching $LOAD_PATH for stubs to optionally delete (may take a while)...
...done.
No library stubs found.
'~p0gem" update --system' は、内部コマンドまたは外部コマンド、
操作可能なプログラムまたはバッチ ファイルとして認識されていません。

色々出て最後に上記のようなメッセ―ジがでたけど、、、無視するか。

もう一度 gem -v をしてみたらなぜか1.0.1にバージョンが戻っていた。
一体どういう仕組み!?

また再度、ruby setup.rb で 1.4.2 にする。


9.Railsのバージョン確認

C:\Rails>rails -v
Rails 2.0.2

10.Railsの更新
またエラーでたよ。。。Ruby1.8.7以上の指示が。でもれこactivesupportやらなのでまぁ無視で。

C:\Rails>rails -v
Rails 2.0.2

C:\Rails>gem update rails
Updating installed gems
Updating rails
Fetching: i18n-0.6.1.gem (100%)
Fetching: multi_json-1.7.2.gem (100%)
Fetching: activesupport-3.2.13.gem (100%)
ERROR:  Error installing rails:
        activesupport requires Ruby version >= 1.8.7.
Gems updated: i18n, multi_json
Installing ri documentation for i18n-0.6.1...
Installing ri documentation for multi_json-1.7.2...
Installing RDoc documentation for i18n-0.6.1...
Installing RDoc documentation for multi_json-1.7.2...

でいろいろやってみたがDB作ったりテーブル作ったりする中でことごとくエラーが出たのであきらめました。

この方の情報が一番わかりやすい
http://pgnote.net/?p=376


■mac

1.ターミナルの起動

2.現在のrubyのバージョン確認

$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin10.0]

3.Homebrewのインストールコマンドの確認
以下のHPの一番下に記載あり。2013.4現在は以下のコマンドを実行する。

$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
-e:67: warning: Insecure world writable dir /usr/local in PATH, mode 040777
-e:88: warning: Insecure world writable dir /usr/local in PATH, mode 040777
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1

Press ENTER to continue or any other key to abort
-e:34: warning: Insecure world writable dir /usr/local in PATH, mode 040777
==> Downloading and Installing Homebrew...
==> Installation successful!
You should run `brew doctor' *before* you install anything.
Now type: brew help

4.バージョン確認

$ brew -v
Homebrew 0.9.4

5.動作確認

$ brew doctor
Warning: Your Xcode (3.2.3) is outdated
Please install Xcode 3.2.6.
You must: brew install git
You must: brew install git

Warning: An outdated version of Git was detected in your PATH.
Git 1.6.6 or newer is required to perform checkouts over HTTP from GitHub.
Please upgrade: brew upgrade git

参考にさせて頂いたサイト
http://d.hatena.ne.jp/honeniq/20120413/1334330947
http://pplog.org/?p=1845