Agile Web Development with Rails 7: 'rails new demo' specifying the Rails version has no affect

This is how RubyGems Semantic Versioning with Pessimistic version constraint works

gem "rails", "~> 7.0.4" # means >= 7.0.4 and < 7.1

Semantic versioning boils down to:

  • PATCH 0.0.x level changes for implementation level detail changes, such as small bug fixes
  • MINOR 0.x.0 level changes for any backwards compatible API changes, such as new functionality/features
  • MAJOR x.0.0 level changes for backwards incompatible API changes, such as changes that will break existing users code if they update

If you use a version specifier like "~> 7.0.4" bundler will always pick the latest patch of the given version 7.0 of the gem.

Most of the version specifiers, like >= 1.0 , are self-explanatory. The specifier ~> has a special meaning, best shown by example. ~> 2.0.3 is identical to >= 2.0.3 and < 2.1 . ~> 2.1 is identical to >= 2.1 and < 3.0 . ~> 2.2.beta will match prerelease versions like 2.2.beta.12 . ~> 0 is identical to >= 0.0 and < 1.0 .

1 Like