16

当我从 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

4 回答 4

6

该错误似乎与您显示的 gemspec 不同步,该错误表示gem.descripton无效。根据错误,您正在使用来自 git 的 Gem,它有一个修复无效 gem.description 的提交

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

bundle update
于 2012-10-24T16:59:27.463 回答
5

这个答案并不适用于所有情况,但如果你的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”字样,并为 提供有效的 HTTP URI spec.homepage,您可以像这样替换它:

  spec.summary       = "Write a short summary, because Rubygems requires one."
  spec.homepage      = "http://website.com"
于 2019-12-08T18:06:57.303 回答
1

我强烈认为在解释器解析您的 gemspec 时会检查TODO或检查。FIXME如果它看到这两个单词中的任何一个,此检查已被编程为抛出错误。我遇到了同样的问题,我通过删除我的 gemspec 中对 TODO 的任何引用来解决它。我在主页会话中放置了一个有效的 uri,一切又开始正常工作

于 2016-12-29T09:55:15.203 回答
0

只是为了补充Ashkan Nasirzadeh 的回答

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

诀窍是

  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 Preston"]
  spec.email       = ["promise@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

就这样。

我希望这会有所帮助

于 2020-04-11T21:09:57.593 回答