Reputation: 899
When i create an app using rails with specified version it is not honoring that, even though the Gemfile write 5.2.1 it upgrades to 5.2.2 in the Gemfile.lock file
This is what i did
gem install rails -v 5.2.1
rails _5.2.1_ new backend-solidus -d postgresql
however during installation log this shows:
Fetching rails 5.2.2
Installing rails 5.2.2
Full logfile: https://pastebin.com/qC6d2wws
Upvotes: 0
Views: 41
Reputation: 28305
This is intentional; it's by design.
Here is the relevant source code, from the current rails
master branch:
def rails_gemfile_entry
if options.dev?
[
GemfileEntry.path("rails", Rails::Generators::RAILS_DEV_PATH)
]
elsif options.edge?
[
GemfileEntry.github("rails", "rails/rails")
]
else
[GemfileEntry.version("rails",
rails_version_specifier,
"Bundle edge Rails instead: gem 'rails', github: 'rails/rails'")]
end
end
def rails_version_specifier(gem_version = Rails.gem_version)
if gem_version.segments.size == 3 || gem_version.release.segments.size == 3
# ~> 1.2.3
# ~> 1.2.3.pre4
"~> #{gem_version}"
else
# ~> 1.2.3, >= 1.2.3.4
# ~> 1.2.3, >= 1.2.3.4.pre5
patch = gem_version.segments[0, 3].join(".")
["~> #{patch}", ">= #{gem_version}"]
end
end
In particular, note the ~>
operator.
The use of this means that, even though your Gemfile
will specify version ~> 5.2.1
, the actual version that bundler
chooses to install is "the latest version that's >= 5.2.1
and < 5.3.0
".
Patch releases contain small changes - such as minor bug fixes and security patches. It is extremely rare that your code will break due to a patch version update; it's far more likely that you'll remain vulnerable to a security vulnerability if you fail to update.
Therefore rails, by default, installs the latest patch of the specified version.
If you really want to explicitly revert to rails 5.2.1
, you may edit the Gemfile
to say:
rails '5.2.1'
then, re-run bundle update
.
Upvotes: 4