Pre-releasing a Ruby gem

When a Ruby version gem has a letter in its version number, it is considered a pre-release:

  • 1.0.0.rc1
  • 2.3.0.alpha2
  • 3.0.0.beta3
  • 4.0.0.pre.rc2

Even if a pre-release gem has the highest version number, it is never installed unless the user explictily requested the version:

gem install foobar --version="=2.3.0.alpha2"

Also bundle update will never update a stable version to a pre-release version unless the user explicitly requests it in the Gemfile:

gem 'foobar', '=2.3.0.alpha2'

A note on Semantic Versioning

Semantic Versioning has a naming convention for pre-releases that is incompatible with that from RubyGems. In Semantic Versioning, the version number and pre-release identifier (like rc1) must be separated by a dash, e.g. 1.0.0-rc1. However, RubyGems versions require version components to be separated by a dot.

When RubyGems sees a version number with a dash, it automatically converts it to a RubyGems-compatible version like this:

Semantic versioning Converted RubyGems version
1.0.0-rc1 1.0.0.pre.rc1
2.3.0-alpha2 2.3.0.pre.alpha2
3.0.0-beta3 3.0.0.pre.beta3

Note that npm packages force you to use Semantic Versioning's naming convention. If your library has both a Ruby and JavaScript component and you want to use the same version constant for both, you can use the npm's convention and let RubyGems auto-convert its own variant.

See also

Henning Koch 3 months ago
This website uses short-lived cookies to improve usability.
Accept or learn more