managing different rails 2.3.x versions in development/production with bundler

560 views Asked by At

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.

1

There are 1 answers

3
corroded On

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.