LeopardでのRubyGems
LeopardでRubyGemsを使おうとすると、sourcesがロードできないと怒られる。
$ sudo gem install mysql /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- sources (LoadError) from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require' from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/source_info_cache.rb:6 from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require' from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/remote_installer.rb:12 from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require' from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems.rb:112:in `manage_gems' from /opt/local/bin/gem:10
これは、rootになるとGEM_PATHが空になってしまい、sourcesが探せなくなるのが原因。
次のようにすれば解決する。もっと賢い方法があったら教えてください。
$ sudo -s # export GEM_PATH=/opt/local/lib/ruby/gems # gem install mysql