Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gem contains itself error for CLI Data gem

I just built a CLI Data gem and published it to RubyGems. Now if I try to do bundle install, I get the following error

``

You have one or more invalid gemspecs that need to be fixed. 
  The gemspec at 
  /home/himachhag-45739/code/popular-deals-from-slickdeals.net-`cli/popular_deals.gemspec` 
  is not valid. Please fix this gemspec. 
  The validation error was 'popular_deals-0.1.0 contains itself 
  (popular_deals-0.1.0.gem), check your files list'

Please see below my gmspec file:

# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'popular_deals/version'

Gem::Specification.new do |spec|
  spec.name          = "popular_deals"
  spec.version       = PopularDeals::VERSION
  spec.authors       = ["'Hima Chitalia'"]
  spec.email         = ["'[email protected]'"]

  spec.summary       = %q{It displays popular deals of the day from https://slickdeals.net/deals/.}
  #spec.description   = %q{It displays popular deals of the day from https://slickdeals.net/deals/.}
  spec.homepage      = "https://github.com/HimaChitalia/popular_deals"
  spec.license       = "MIT"

  spec.files         = `git ls-files -z`.split("\x0").reject do |f|
     f.match(%r{^(test|spec|features)/})
   end
    spec.bindir        = "exe"
   spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
   spec.require_paths = ["lib"]

  spec.add_development_dependency "bundler", "~> 1.14"
  spec.add_development_dependency "rake", "~> 10.0"
  spec.add_development_dependency "pry"

  spec.add_dependency "nokogiri"
  spec.add_dependency "colorize"

end

What should I do to fix this? Thank you in advance for your help.

like image 585
Hima Chhag Avatar asked Apr 03 '17 21:04

Hima Chhag


2 Answers

From http://siawyoung.com/coding/ruby/invalid-gemspec.html

It turns out this happens because the gemspec gets the list of files from the command

`git ls-files -z`.split("\x0")

So remove the file popular_deals-0.1.0.gem from the repository and it should work.

like image 162
otaviko Avatar answered Sep 22 '22 14:09

otaviko


rm popular_deals-0.1.0.gem
git add .
bundle install

Notice, you need git add . before bundle install, because you need update list of files.

like image 20
vk26 Avatar answered Sep 19 '22 14:09

vk26