gem 自身包含 CLI 数据错误 gem

gem contains itself error for CLI Data gem

我刚刚构建了一个 CLI 数据 gem 并将其发布到 RubyGems。现在,如果我尝试进行捆绑安装,我会收到以下错误

``

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'

请看下面我的 gmspec 文件:

# 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         = ["'hima_chhag@yahoo.com'"]

  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

我应该怎么做才能解决这个问题?预先感谢您的帮助。

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

事实证明这是因为 gemspec 从命令中获取文件列表

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

所以从存储库中删除文件 popular_deals-0.1.0.gem,它应该可以工作。

rm popular_deals-0.1.0.gem
git add .
bundle install

注意,您需要git在捆绑安装之前添加.,因为您需要更新文件列表。

我发现另一个答案不符合我的需要,那就是将我所有不同的版本上传到我的存储库。

几分钟前我遇到了同样的问题,请尝试将您的 gemspec 'files' 属性 修改为:

spec.files = Dir.glob("{bin,lib}/**/*")

让我知道它是否适合你。