RubyonRailsを試してみた

2010年が始まったということで、先延ばしになっていたMacによるrails開発を再開。
まずはこちらを参照しながら、localでrailsを動作させてみる。

しかし、このp124のところで

ruby script/console

を実行すると次のエラーが出てしまう。

Loading development environment (Rails 2.3.5)
Rails requires RubyGems >= 1.3.2 (you have 1.0.1). Please `gem update --system` and try again.

うーん。

gem -v
1.3.5

なんだけど、と思い、binを調べてみると、

cd /usr/bin
ls -la | grep "gem"
lrwxr-xr-x 1 root wheel 71B 11 7 2008 gem.org@ -> ../../System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem
lrwxr-xr-x 1 root wheel 83B 11 7 2008 update_rubygems.org@ -> ../../System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/update_rubygems

あー、gem.org@というシンボリックリンクが存在しているので、そのシンボリックリンクの先のgemをupdate.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem update --system
Updating RubyGems...
Bulk updating Gem source index for: http://gems.rubyforge.org
Bulk updating Gem source index for: http://gems.github.com
Attempting remote update of rubygems-update
Successfully installed rubygems-update-1.3.5
1 gem installed
Installing ri documentation for rubygems-update-1.3.5...
Installing RDoc documentation for rubygems-update-1.3.5...
Could not find main page README
Could not find main page README
Could not find main page README
Could not find main page README
Updating version of RubyGems to 1.3.5
Installing RubyGems 1.3.5
RubyGems 1.3.5 installed

=== 1.3.5 / 2009-07-21

Bug fixes:

Fix use of prerelease gems.
Gem.bin_path no longer escapes path with spaces. Bug #25935 and #26458.

Deprecation Notices:

Bulk index update is no longer supported (the code currently remains, but not
the tests)
Gem::manage_gems was removed in 1.3.3.
Time::today was removed in 1.3.3.

                                                                                                                                                          • -

RubyGems installed the following executables:
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem

RubyGems system software updated

これでできたと思って再度実行したところ、またエラーが発生

ruby script/console
Loading development environment (Rails 2.3.5)
Missing the Rails 2.3.5 gem. Please `gem install -v=2.3.5 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.

railsは2.3.5を入れてあるんだけど・・・
どうやら、元々入っているrailsを参照しているらしい。
恐らく、ruby1.9ソースコードから導入した際に、元々入っているrubyrailsが悪さしている模様。

もう一度、MacPorts使ってインストールしなおそうか検討中。