Getting Started
Guides
Dependency Management
- How to manage application dependencies with Bundler
- How to manage dependencies with Bundler
- How to update gems with Bundler
- How to manage groups of gems
- How to install gems from git repositories
- How to develop multiple gems in one repository
- How to use Bundler with Ruby
- How to use Bundler in a single-file Ruby script
- How to deploy bundled applications
Gem Development
Publishing & Security
- Trusted Publishing
- Setting up multi-factor authentication
- Using multi-factor authentication in command line
- Managing owners using UI
- Organizations
- Removing a Published gem
- Security Practices
- How to delay new gem versions with cooldown
Integrations
- How to use Bundler with Rails
- How to use Bundler with Sinatra
- How to use Bundler with Docker
- How to use Bundler in CI
Hosting & Sources
Extending
Troubleshooting
- Troubleshooting common issues
- How to troubleshoot RubyGems and Bundler TLS/SSL Issues
- How to use git bisect with Bundler
Concepts
- What is a gem?
- Gemfile and gemspec
- Where gems are installed and how they load
- How dependency resolution works
- How Gemfile.lock works
- Versioning and compatibility
- Platforms and native gems
- Caching and vendoring
- Default gems and bundled gems
- Common Vulnerabilities and Exposures
Reference
- gem Command Reference
- Bundler Command Reference
- Gemfile Reference
- Ruby Directive
- Specification Reference
- RubyGems.org API
- RubyGems.org Compact Index API
- RubyGems.org rate limits
- API key scopes
- Bundler compatibility with Ruby
- Configuration (.gemrc)
- Environment variables
- Known Bundler Plugins
Appendix
Name your gem
Our recommendation on the use of “_” and “-“ in your gem’s name.
Here are some examples of our recommendations for naming gems:
| Gem name | Require statement | Main class or module |
|---|---|---|
ruby_parser |
require 'ruby_parser' |
RubyParser |
rdoc-data |
require 'rdoc/data' |
RDoc::Data |
net-http-persistent |
require 'net/http/persistent' |
Net::HTTP::Persistent |
net-http-digest_auth |
require 'net/http/digest_auth' |
Net::HTTP::DigestAuth |
The main goal of these recommendations is to give the user some clue about how to require the files in your gem. Following these conventions also lets Bundler require your gem with no extra configuration.
If you publish a gem on rubygems.org it may be removed if the name is objectionable, violates intellectual property or the contents of the gem meet these criteria. You can report such a gem to support@rubygems.org via email.
Use underscores for multiple words
If a class or module has multiple words, use underscores to separate them. This matches the file the user will require, making it easier for the user to start using your gem.
Use dashes for extensions
If you’re adding functionality to another gem, use a dash. This usually
corresponds to a / in the require statement (and therefore your gem’s
directory structure) and a :: in the name of your main class or module.
Mix underscores and dashes appropriately
If your class or module has multiple words and you’re also adding functionality
to another gem, follow both of the rules above. For example,
net-http-digest_auth adds
HTTP digest authentication to net/http.
The user will require 'net/http/digest_auth' to use the extension
(in class Net::HTTP::DigestAuth).
Don’t use UPPERCASE letters
OS X and Windows have case-insensitive filesystems by default. Users may mistakenly require files from a gem using uppercase letters which will be non-portable if they move it to a non-windows or OS X system. While this will mostly be a newbie mistake we don’t need to be confusing them more than necessary.
Credits
This guide was expanded from How to Name Gems by Eric Hodel.