How to make different development and production declaration of my rails engine in a gemset

118 views Asked by At

I made an engine and try to use it in a project. I would like to use the packaged engine on production and link to the project sources on development.

I add the following lines into the project's Gemfile.

gem 'mygem', '0.0.2', group: :production
gem 'mygem', '0.0.2', :path => '../mygemproject',  group: [:development, :test]

As a result, I've got an error 'You cannot specify the same gem twice coming from different sources.'.

Is there a different way to do what I want ?

Edit

I read that Bundle don't know about Rails environment so I try this

group :development, :test do
  gem 'mygem',  '0.0.2', :path => '../mygemproject'
end

group :production do
 gem 'mygem',  '0.0.2'
end

Then I execute Bundle with the 'without' argument, I'd rather not doing that but I try

 bundle install --without production

Even like this I still have the 'cannot specify same gem twice' error.

1

There are 1 answers

2
Archie Reyes On

Just add your gem outside of the group so that it will be available in your development, test or production.

Gemfile

gem 'mygem', '0.0.2'

group :development, :test do
end

group :test do
end

group :production do
end