How to use 2.1 gem dependencies

Gem dependencies seems to be caught in a catch-22: if I put a config.gem
statement in environment, and then write some code to use that gem in a
rake task or in a controller (such as a ‘require’ statment), then rake
will no longer work. It is broken, because the gem is not installed.
Moreover, I can’t install the gem, because rake is broken when it tries
to load the envioronment.

How do I get around this? This seems like a core deployment scenario, I
can’t help but feel like I am missing some key part of 2.1 gem
dependencies.

Here’s a specific example:

run: rails /home/user/test/
edit: enviornment.rb, uncomment the line config.gem “bj”
add: test.rake to ./lib/tasks
edit: test.rake:

namespace :test do
require ‘bj’
desc ‘test’
task :test => :environment do
puts Time.now
end
end

run: rake gems:install

the last command will fail, because the bj gem is not there.