Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gemfile - separating Production gems from Development gems

So I know that in a Gemfile I can do something like this:

group :development, :test do
  gem 'gem1'
  gem 'gem2'
end

What I am looking to accomplish is something like this:

group :production do
  gem 'gem1'
  gem 'gem2'
end

group :development, :test do
  gem 'gem1', :path => '/Documents/Code/gem1/'
  gem 'gem2', :path => '/Documents/Code/gem2/'
end

So our application uses 2 gems that we also develop locally. In order to improve time while developing on our local machines, we want to be able to point our dev environments to the local copies of the gems - this way it picks up all changes without needing to restart our rails server. Otherwise we would have to rebuild the gem, re-install the gem, and restart rails with every development change in the gem.

However, doing this gives me the following error:

You cannot specify the same gem twice coming from different sources. You specified that gem1 (>= 0) should come from an unspecfied source and source at /Documents/Code/gem1

I have tried even running something like bundle install --without production and I get the same error.

Does anyone know if it IS possible to do what I would like to do?

Thanks!

like image 329
Krista Avatar asked Dec 21 '22 15:12

Krista


1 Answers

i think that there is a supported way to do it and some hacks to work around it.

supported way:

use bundle config with the local option as described here: http://bundler.io/v1.3/man/bundle-config.1.html

hacky way:

use env vars and execute bundler before using in production: http://www.cowboycoded.com/2010/08/10/using-2-sources-for-a-gem-in-different-environments-with-bundler/

there is a feature-request for this problem on github with several related issues and lots of comments: https://github.com/carlhuda/bundler/issues/396

like image 184
phoet Avatar answered Jan 13 '23 16:01

phoet