NPM has the ability to prevent a gem from being published. Is there a way to do the same thing and prevent a gem from being accidentally published to rubygems?
require 'rubygems' will adjust the Ruby loadpath allowing you to successfully require the gems you installed through rubygems, without getting a LoadError: no such file to load -- sinatra .
When you use the --user-install option, RubyGems will install the gems to a directory inside your home directory, something like ~/. gem/ruby/1.9. 1 . The commands provided by the gems you installed will end up in ~/.
Ruby comes with RubyGems by default since version 1.9, previous Ruby versions require RubyGems to be installed by hand.
RubyGems 2.2.0 was only recently released, which adds support for this. You need to set allowed_push_host
to your own gem server. The documentation describes it thus:
If you want to control who can install a gem, or directly track the activity surrounding a gem, then you’ll want to set up a private gem server. You can set up your own gem server or use a commercial service such as Gemfury.
RubyGems 2.2.0 and newer support the
allowed_push_host
metadata value to restrict gem pushes to a single host. If you are publishing private gems you should set this value to prevent accidental pushes to rubygems.org:
Gem::Specification.new 'my_gem', '1.0' do |s|
# ...
s.metadata['allowed_push_host'] = 'https://gems.my-company.example'
end
To upgrade RubyGems, just run the following command:
gem update --system
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With