1

I'm trying to configure Bundler to work with different Rails 2.3.x versions using the guide in the bunder website, so I could test a version in dev environment before its used in production. I have the following Gemfile:

# some common gems

group :development do
  # installed on dev machine
  gem "rails", "2.3.11" 

  #... some more dev gems
end

group :production do
  gem "rails", "2.3.8", :path => 'vendor/rails'
end

When I try to run the server in dev mode, I get a bundler error You cannot specify the same gem twice with different version requirements. You specified: rails (= 2.3.11) and rails (= 2.3.8) (Bundler::DslError). What am I missing? I thought the goal of Bundler was to help me do just that. thanks.

sa125
  • 28,121
  • 38
  • 111
  • 153

1 Answers1

1

http://gembundler.com/groups.html

I think you just need to specify which group you're installing. I think by default it just goes through all the groups, so just specify what you don't need.

bundle install --without production

from the same page:

Require the gems in particular groups, noting that gems outside of a named group are in the :default group

Bundler.require(:default, :development)

Require the default gems, plus the gems in a group named the same as the current Rails environment

Bundler.require(:default, Rails.env)

In this case, you need the second one.

corroded
  • 21,406
  • 19
  • 83
  • 132
  • I appreciate the tip, although I'm not trying to install gems, just run script/server - gems are either installed on the machine or available in vendor/gems. I get that error when rails is trying to initialize. – sa125 Feb 24 '11 at 06:37
  • 1
    then you just have to require certain gems depending on your environment. if you read that page, check out my edited answer – corroded Feb 24 '11 at 06:44
  • the Bundler.require(..) solution doesn't seem to work for different gem sources like I have it set up (still get that error). I looked into it, and it seems to be planned for Bundler 1.1 (at least according to this http://bit.ly/bjdk0C). Thanks again! – sa125 Feb 24 '11 at 06:57