Unable to install Ruby gems
I am trying for the first time to install some Ruby gems on Mac OS X Leopard. Please see the command and the output below. My question is how do I install a gem with dependencies? I tried installing individual depend开发者_如何转开发ency gems first from a locally downloaded files but I soon found out that there is no end to the rabbit hole :-) I also found out that there are circular dependencies that break even this tedious method. There must be a better way! I would really appreciate your help.
sudo gem install oauth
Updating metadata for 1 gems from http://gems.rubyforge.org
.
complete
ERROR: Error installing oauth:
oauth requires actionpack (>= 2.2.0, < 2.3.0)
try
sudo gem install --include-dependencies oauth
if that doesn work
try installing rails (actionpack is part of rails) first
sudo gem install rails
sudo gem install oauth
Bundler is the new ruby gem dependency management system. You can create a Gemfile at the root of your application, and add gem "oauth"
to the file (you also need a source such as source :gemcutter
. Then running bundle install
will take care of all dependencies for you. Read the docs linked above for more information.
Here's a sample Gemfile of mine:
source :gemcutter
gem "rails", "2.3.5"
gem "nokogiri"
gem "memcache-client", "1.7.8", :require => "memcache"
group :test do
gem "factory_girl"
gem "cucumber"
gem "webrat"
end
In addition to this, check out RVM (Ruby Version Manager). It allows you to run multiple ruby versions. When using rvm, all gems will be installed in your home directory rather than system wide so you can omit the sudo.
Ryan Bates also has some great railscasts on RVM and Bundler
精彩评论