我正在尝试编译我的第一个gem并将其推送到rubygems.org。它不断抛出错误,说我无法推送到https://rubygems.org:
gem build simplesms.gemspec
WARNING: licenses is empty, but is recommended. Use a license identifier from
http://spdx.org/licenses or 'Nonstandard' for a nonstandard license.
WARNING: no homepage specified
WARNING: See http://guides.rubygems.org/specification-reference/ for help
Successfully built RubyGem
Name: simplesms
Version: 0.1.0
File: simplesms-0.1.0.gem
Toms-MacBook-Pro-2:simplesms t$ gem push simplesms-0.1.0.gem
Pushing gem to https://rubygems.org...
ERROR: "https://rubygems.org" is not allowed by the gemspec, which only allows "'http://rubygems.org'"
但在我的规格中:
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'simplesms/version'
Gem::Specification.new do |spec|
spec.name = "simplesms"
spec.version = Simplesms::VERSION
spec.authors = ["Tom"]
spec.email = ["tom@example.com"]
spec.summary = %q{Easily add sms to your project by integrating the Simple SMS Heroku Addon into your app.}
spec.homepage = ""
# 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'] = "'http://rubygems.org'"
else
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
end
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.add_development_dependency "bundler", "~> 1.12"
spec.add_development_dependency "rake", "~> 10.0"
end
在gemfile中:
source 'http://rubygems.org'
# Specify your gem's dependencies in simplesms.gemspec
gemspec
只是为了踢,我也尝试将它们设置为' https://rubygems.org'但是它仍会引发同样的错误。
知道我需要做什么才能将其推送到rubygems.org?我已使用我的电子邮件/密码登录,并确认凭据位于~/.gem/credentials
答案 0 :(得分:3)
这一行:
spec.metadata['allowed_push_host'] = "'http://rubygems.org'"
您将allowed_push_host
设置为'http://rubygems.org'
。它应该只是http://rubygems.org
(没有单引号)。将其更改为:
spec.metadata['allowed_push_host'] = "http://rubygems.org"
同样允许https://rubygems.org
安全(并且首选)。