Gemfile - Separating Manufactured Gemstones from Gemstone Design

Therefore, I know that in Gemfile I can do something like this:

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

I want to do the following:

 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 

Thus, our application uses 2 stones, which we also develop locally. To improve development time on our local machines, we want our Dev environments to point to local copies of the gemstones - this way it gets all the changes without having to restart our rails server. Otherwise, we would have to rebuild the gem, reinstall the gem and restart the rails with each change in development in the gem.

However, this results in 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 even tried running something like bundle install --without production and I get the same error.

Does anyone know if I can do what I would like to do?

Thanks!

+4
source share
3 answers

I think there is a supported way to do this and some hacks to get around it.

supported method:

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

hacked way:

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

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

+5
source

phoet-related github issue has been fixed and is consistent with the supported method.

I dug in the docs, you need to set the config variable and update your gemfile to also reference the branch.

eg.

edit your gemfile:

 gem <gem_name>, git: <git_url>, branch: <branch> 

on the command line:

 bundle config local.<gem_name> <local_path_to_gem> 
+5
source

I solved this by creating a new Gemfile that is identical to the original, with the exception of the target gem source. Then in config / boot.rb I used:

require 'rails' if Rails.env.development? ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../DevGemfile', __FILE__) else ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../ProdGemfile', __FILE__) end

0
source

Source: https://habr.com/ru/post/1438718/


All Articles