Reputation: 6080
I'm trying to compile my first gem and push it to rubygems.org. It keeps throwing an error saying I can't push to 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'"
But in my spec:
# 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 = ["[email protected]"]
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
In the gemfile:
source 'http://rubygems.org'
# Specify your gem's dependencies in simplesms.gemspec
gemspec
Just for kicks I also tried setting them to 'https://rubygems.org', however it still throws the same error.
Any idea what I need to do to get this to push to rubygems.org? I already signed in with my email/password and confirmed the credentials are in ~/.gem/credentials
Upvotes: 3
Views: 1098
Reputation: 410542
This line:
spec.metadata['allowed_push_host'] = "'http://rubygems.org'"
You're setting allowed_push_host
to 'http://rubygems.org'
. It should just be http://rubygems.org
(without the single quotes). Change it to:
spec.metadata['allowed_push_host'] = "http://rubygems.org"
It should be safe (and preferred) to allow https://rubygems.org
instead, too.
Upvotes: 6