我正试图编译我的第一个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
中
此行:
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
也应该是安全的(也是首选的)。