Read more

Pre-releasing a Ruby gem

Henning Koch
May 03, 2021Software engineer at makandra GmbH

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
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

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

Posted by Henning Koch to makandra dev (2021-05-03 11:44)