tags:

views:

178

answers:

2

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 dependency 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)  
A: 

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

brad
A: 

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
DrewM
Thank you for this answer. I tried --include-dependencies and received an INFO message telling me that this option is enabled by default. So this did not help with the issue. Then I tried installing rails and received an error "could not find rails locally or in a repository" It looks like I may be missing something. By the way I am using gem installed with Mac OS X Leopard. Thank you for any additional insights.
try gem update --system to upgrade to the latest and then try installing rails again
DrewM
The update allowed me to install oauth with all dependencies even without rails install! The update also changed the main gem source to http://rubygems.org. So the issue has been resolved. Thank you very much!