Rails:Gemspec无效。请修复此gemspec。

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

我该如何修复这个错误?


1
你是怎么解决这个问题的?我也遇到了一个类似的问题! - Emna Ayadi
4个回答

6
错误似乎与您展示的gemspec不同步,错误指出gem.descripton无效。根据该错误,您正在使用来自git的Gem,其中有一个修复无效的gem.description的提交
请让Bundler更新到最新的number_internationalizer提交:
bundle update

我已经这样做了,现在当我尝试运行rails s时,会出现Could not find i18n-0.6.1 in any of the sources的错误。我运行了bundle show i18n,答案是/usr/local/rvm/gems/ruby-1.9.3-p194@number_internationalizer/gems/i18n-0.6.1。我不确定为什么会出现@number_internationalizer - Bishma Stornelli
2
我找到了新错误的解决方案。我之前使用过 rvm gemset use number_internationalizer 。我必须重置 rvm。 - Bishma Stornelli

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" 一词,并为 spec.homepage 提供有效的 HTTP URI,您可以像这样进行替换:

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

1
我强烈感觉在解释器解析您的gemspec时,有一个检查TODO或FIXME的功能。如果它看到这两个单词中的任何一个,该检查已被编程为抛出错误。我曾经遇到过同样的问题,并通过删除gemspec中对TODO的任何引用来解决它。我在主页会话中放置了有效的URI,然后一切都重新开始正常工作了。

更改了TODOFART,并且bundle install成功。 - Salomanuel

0

只是想要补充Ashkan Nasirzadeh的答案

我在Rails 6.0.2.2应用程序中使用Rails引擎时遇到了类似的问题。

诀窍是:

  1. 删除your_engine.gemspec文件中每个TODO的出现。
  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

就是这样了。

希望这能帮到你。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接