- Next »
- « Previous
Rails rake gems:install
Rails rake gems:install
With ruby on rails there's a great little task rake gems:install which will install any required gems for your app, which you have specified in your configuration environment.
The problem is your plugins and models will most likely require those gems, and the rake task will load the environment, thus load the plugins and models, etc. before it installs the require gems.
A classic catch22 scenario.
There is no real purpose to load the environment at all, but commenting out that line will bring up various other errors, instead you can let it load the first part of the environment you need, rescue the inevitable exception, then it will install the gems as required
So in rails/lib/gems.rake you will see:
namespace :gems do
task :base do
$gems_rake_task = true
require 'rubygems'
require 'rubygems/gem_runner'
begin
Rake::Task[:environment].invoke
rescue
end
end
...
end
Replace:
Rake::Task[:environment].invoke
With:
begin
Rake::Task[:environment].invoke
rescue
end
And things work like you would except.
Obviously not the ideal solution, but it gets the job done quickly