Difference between $Bundle install and $Bundle update
Ruby on-RailsRuby on-Rails Problem Overview
Could you tell me, whats the difference between:
$Bundle update
and
$Bundle install
Ruby on-Rails Solutions
Solution 1 - Ruby on-Rails
bundle update
and bundle install
can both install the gems you specified in Gemfile but missing in gems.
But bundle update
does one thing more to upgrade:
-
If the gems specified in Gemfile don't have version, it will upgrade to whatever latest.
-
If the gems specified in Gemfile have version controlled with
~>
, it will upgrade to the latest at the final digit, the patch version.For example, if you have a gem in Gemfile
'foo_gem', '~> 2.1.0'
bundle update
will check if newer version of 2.1.x is available in cloud. Say your current version is 2.1.2 and what's latest in cloud is 2.1.5, it will install 2.1.5. But if2.2.6
is the newest, it won't do anything.
Better practice in my opinion
-
Always add version to critical gems like
rails
. -
Stick to
bundle install
(orbundle
which is default toinstall
) in most cases. Only dobundle update
when it's really necessary and you are fully prepared for the result.
Solution 2 - Ruby on-Rails
Bundle Update
s the gems specified (all gems, if none are specified), ignoring the previously installed gems specified in the Gemfile.lock. In general, you should use bundle install
to install the same exact gems and versions across machines.