Problem with rake gems:install

Hi list.

I've added the following line to my `config/environment.rb` file, within the `Initializer`:

    config.gem 'mislav-will_paginate', :version => '2.3.11', :lib => 'will_paginate', :source => 'http://gems.github.com'

When I then run the command `sudo rake gems:install`, I get the following output:

    tkn@tkn-desktop-ubuntu ~/work/trunk $ sudo rake gems:install     (in /home/tkn/work/trunk)     Missing these required gems:       mislav-will_paginate = 2.3.11

    You're running:       ruby 1.8.6.287 at /usr/local/bin/ruby       rubygems 1.3.1 at /home/tkn/.gem/ruby/1.8, /usr/local/lib/ruby/gems/1.8

    Run `rake gems:install` to install the missing gems.

What is going on here?

What version of rails are you running?

--Matt Jones

More info on the matter here (And a hackety workaround):

http://www.railsforum.com/viewtopic.php?id=28417

You shouldn't be seeing this problem with 2.3.2 - I just tried it in a fresh Rails app using the 2.3.2 gem. Something weird's going on in your version, as the install task sets $gems_rake_task which *should* prevent the display of the error message you're seeing.

Do you happen to have an RC version frozen in vendor/rails? That's my next guess...

--Matt Jones

I have exactly the same problem with Rails 2.3.2. Since it is an open source project, you can easily grab it from here and verify for yourself the problem:

http://github.com/ari/clockingit/tree/master

Ari Maniatis

Ari: your problem is in lib/tasks/localization.rake. You require config/environment, which loads the initializer and causes the error. The gems tasks never even get a chance to run.

Troels - I'd recommend that you look for the same kind of thing in your Rakefiles.

--Matt Jones

Matt: thank you so much for finding that. I have removed it and the problem goes away as you say. Can I recommend some improvements to Rails to help others in this predicament:

* rake gems:install should not try to load all the rake tasks since it has a very specific job to do and should not be sidetracked by loading everything it comes across on the class path

* better error reporting which detects this condition and reports where the problem might lie

Thank you again for your help.

Ari Maniatis

FYI, I have created a plugin, that moves gem-dependencies into a separate file (`config/gemconf.rb`) and then makes `script/install_gems` use this file for finding dependencies. This makes the install script completely independent of rake and any rake tasks.

http://github.com/troelskn/gemconf_plugin/tree/master

You can install it to you existing Rails projects, using:

    ./script/plugin install http://github.com/troelskn/gemconf_plugin/tree/master

Hope this helps someone.