Today I Learned

hashrocket A Hashrocket project

Using pessimistic gem version to catch betas

The trouble with pessimistic (~>) versioning is that it still won't catch pre-release library versions... or will it.

It actually can allow 'beta' versions by adding an 'x' to the version you'd like to catch.

gem "rails", "~> 5.x"

Since 'beta' versions (5.0.0.beta3) actually register as higher than 5.0.0, the pessimistic operator will not catch the beta version. Gem versioning shows any version with a letter as 'pre-release' which is how beta3, rc1, alpha versions work.

Using the 'x' as a wildcard will allow pre-release gem versions to be caught.

See More #ruby TILs
Looking for help? Each developer at Hashrocket has years of experience working with Ruby applications of all types and sizes. We're an active presence at Ruby conferences, have written some of the most popular gems, and have worked on many of the web's Ruby on Rails success stories. Contact us today to talk about your Ruby project.