Pre-releasing a Ruby gem

Posted . Visible to the public.

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 Show archive.org snapshot 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
Last edit
Henning Koch
Keywords
prerelease, alpha, beta, rc
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2021-05-03 09:44)