对于CLI Data gem,gem包含自身错误

时间:2017-04-03 21:02:44

标签: ruby rubygems bundle

我刚刚构建了一个CLI Data 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

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

3 个答案:

答案 0 :(得分:7)

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

事实证明这是因为gemspec从命令

获取文件列表
`git ls-files -z`.split("\x0")

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

答案 1 :(得分:2)

rm popular_deals-0.1.0.gem
git add .
bundle install

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

答案 2 :(得分:0)

我发现另一个无法满足我需要的答案是将所有不同版本上传到我的仓库中。

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

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

让我知道它是否对您有用。