如何修复无效的gemspec?

时间:2012-10-24 16:50:40

标签: ruby-on-rails rubygems gemspecs

当我从github安装gem时,它给出了错误:

number_internationalizer at /usr/local/rvm/gems/ruby-1.9.3-p194@number_internationalizer/bundler/gems/number_internationalizer-c0d642b04e87 did not have a valid gemspec.
This prevents bundler from installing bins or native extensions, but that may not affect its functionality.
The validation message from Rubygems was:
  "FIXME" or "TODO" is not a description

gemspec是:

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

Gem::Specification.new do |gem|
  gem.name          = "number_internationalizer"
  gem.version       = NumberInternationalizer::VERSION
  gem.authors       = ["Myself"]
  gem.email         = ["myemail@email.com"]
  gem.description   = %q{Internationalize numbers adding normalization, validation and modifying the number field to restor the value to its original if validation fails}
  gem.summary       = gem.description
  gem.homepage      = ""

  gem.files         = `git ls-files`.split($/)
  gem.executables   = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
  gem.test_files    = gem.files.grep(%r{^(test|spec|features)/})
  gem.require_paths = ["lib"]
end

如何修复该错误?

4 个答案:

答案 0 :(得分:4)

该错误似乎与您显示的gemspec不同步,错误表示gem.descripton无效。根据错误,您正在使用来自git的Gem,它具有commit fixing the invalid gem.description

让Bundler更新到最新的number_internationalizer提交:

bundle update

答案 1 :(得分:1)

我强烈感觉在解释器解析你的gemspec时会检查TODOFIXME。如果检查到这两个单词中的任何一个,则此检查已被编程为抛出错误。我有同样的问题,我通过在我的gemspec中删除对TODO的任何引用来解决它。我在主页会话中放了一个有效的uri,一切都恢复正常了

答案 2 :(得分:0)

此答案并非在所有情况下都适用,但是如果您在blob.gemspec文件中有这样的话:

  spec.summary       = "TODO: Write a short summary, because Rubygems requires one."
  spec.homepage      = "TODO: Put your gem's website or public repo URL here."

您应该从中删除“ TODO”字样,并为spec.homepage提供有效的HTTP URI,您可以像这样替换它:

  spec.summary       = "Write a short summary, because Rubygems requires one."
  spec.homepage      = "http://website.com"

答案 3 :(得分:0)

只需添加到Ashkan Nasirzadeh's answer

在Rails 6.0.2.2应用程序中使用Rails Engine时,我也遇到了类似的情况。

诀窍是

  1. 删除TODO文件中每次出现的your_engine.gemspec
  2. 将您选择的网站以双引号添加到spec.homepage
  3. 确保在删除每次出现的TODO的值周围保持双引号,以避免出现undefined method of for main:Object错误。

下面是一个经过适当修改的示例your_engine.gemspec文件。

$:.push File.expand_path("lib", __dir__)

# Maintain your gem's version:
require "app_component/version"

# Describe your gem and declare its dependencies:
Gem::Specification.new do |spec|
  spec.name        = "app_component"
  spec.version     = AppComponent::VERSION
  spec.authors     = ["Promise Chukwuenyem"]
  spec.email       = ["promisepreston@gmail.com"]
  spec.homepage    = "http://website.com"
  spec.summary     = "Summary of AppComponent"
  spec.description = "Description of AppComponent"
  spec.license     = "MIT"

  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
  # to allow pushing to a single host or delete this section to allow pushing to any host.
  if spec.respond_to?(:metadata)
    spec.metadata["allowed_push_host"] = "Set to 'http://mygemserver.com'"
  else
    raise "RubyGems 2.0 or newer is required to protect against " \
      "public gem pushes."
  end

  spec.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]

  spec.add_dependency "rails", "~> 6.0.2", ">= 6.0.2.2"

  spec.add_development_dependency "sqlite3"
end

仅此而已。

我希望这对您有帮助