Skip to content

Component method in main Gemfile generates error when running 'bundle install' #3

@maiksimov

Description

@maiksimov

I am trying to attempt your code into my project. I added component and eval_gemfile_patch scripts the lib folder of my main application. I have an admin_panel engine that is included in the main Gemfile as written in the guide:

component 'admin_panel'

Engine Gemfile looks like:

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gemspec
eval_gemfile './Gemfile.runtime'

Engine admin_panel.gemspec looks like:

$LOAD_PATH.push File.expand_path('lib', __dir__)
require 'admin_panel/version'

Gem::Specification.new do |spec|
  spec.name        = 'admin_panel'
  spec.version     = AdminPanel::VERSION
  spec.summary     = 'AdminPanel.'
  spec.description = 'AdminPanel provides functionality to manage project entities'

  spec.add_dependency 'activeadmin'
  spec.add_dependency 'devise'
  spec.add_dependency 'draper'
  spec.add_dependency 'dry-validation', '~> 1.5'
  spec.add_dependency 'omniauth', '~> 1.9.1'
  spec.add_dependency 'omniauth-google-oauth2'
  spec.add_dependency 'omniauth-rails_csrf_protection'
  spec.add_dependency 'rails', '~> 6.0.3', '>= 6.0.3.2'
  spec.add_dependency 'reform', '~> 2.3'
  spec.add_dependency 'sassc-rails'
  spec.add_dependency 'trailblazer', '~> 2.1'

  spec.add_development_dependency 'bundler'
  spec.add_development_dependency 'combustion', '~> 1.3'
  spec.add_development_dependency 'factory_bot'
  spec.add_development_dependency 'ffaker'
  spec.add_development_dependency 'pg'
  spec.add_development_dependency 'pry-byebug'
  spec.add_development_dependency 'rake', '~> 13.0'
  spec.add_development_dependency 'rspec', '~> 3.0'
  spec.add_development_dependency 'rspec-rails'
  spec.add_development_dependency 'strong_migrations'
end

When I run bundle install I had an error:

[!] There was an error parsing `Gemfile`: 
[!] There was an error parsing `Gemfile`: You cannot specify the same gem twice coming from different sources.
You specified that admin_panel (>= 0) should come from source at `engines/admin_panel` and source at `.`
. Bundler cannot continue.

 #  from engines/admin_panel/Gemfile:6
 #  -------------------------------------------
 #  
 >  gemspec
 #  
 #  -------------------------------------------
. Bundler cannot continue.

 #  from /app/Gemfile:171
 #  -------------------------------------------
 #  # Admin panel
 >  component 'admin_panel'
 #  -------------------------------------------

If I remove the gemspec call from the engine Gemfile, everything works fine, but it looks strange because I want to reuse this engine in other applications.
The same will happen if I use your generators and create some kind of test engine or gem. It generates engine with Gemfile with gemspec call inside. And "bundle install" will throw an error again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions