LoginSignup
2
2

More than 5 years have passed since last update.

Prevent Private Gem Being Published to RubyGems.org

Posted at

Usually we make gems with Bundler like bundle gem or rails plugin new. Bundler provides several useful rake tasks, including rake release to publish it to RubyGems.org.

This is good for Open Source gems, but when you're building a gem for private use only, it would be very bad if you accidentally release it to RubyGems.org: you cannot remove it immediately, instead you can only "yank" it from the index, and you have to ask the admin to remove it completely.

"Yank" only removes it from index, so that others cannot find it anymore, but if any other existing gems depends on it, it can still be installed, which means that the package is still on RubyGems.org and is downloadable. I did once released a private gem to RubyGems.org accidentally, and it took 2 months until it was pulled down since I sent a removal request.

So can we prevent it being published to RubyGems.org? Yes. Starting from Bundler 1.3.0 there is a gem_push environment variable you can use. Set it to falsy string and the gem won't be published onto RubyGems.org:

# Add this line at the top of Rakefile in your gem
ENV['gem_push'] = 'off' # Never Push to Rubygems

Note: I tried setting it to false (boolean lexical value) but it didn't work; the error message would be "no implicit conversion of false into String."

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2