$Bundle 安装和 $Bundle 更新之间的区别 [英] Difference between $Bundle install and $Bundle update
问题描述
你能告诉我,两者之间有什么区别:
Could you tell me, whats the difference between:
$Bundle update
和
$Bundle install
推荐答案
bundle update
和 bundle install
都可以安装您在 Gemfile 中指定但在 gems 中缺少的 gem.
bundle update
and bundle install
can both install the gems you specified in Gemfile but missing in gems.
但是 bundle update
还做了一件事来升级:
But bundle update
does one thing more to upgrade:
- 如果 Gemfile 中指定的 gem 没有版本,它将升级到最新版本.
如果 Gemfile 中指定的 gem 具有使用
~>
控制的版本,它将升级到最新的最后一位,补丁版本.
- 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.
例如,如果您在 Gemfile 中有一个 gem
For example, if you have a gem in Gemfile
'foo_gem', '~> 2.1.0'
bundle update
将检查云中是否有更新的 2.1.x 版本.假设您当前的版本是 2.1.2,而云中的最新版本是 2.1.5,它将安装 2.1.5.但是如果 2.2.6
是最新的,它不会做任何事情.
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 if 2.2.6
is the newest, it won't do anything.
我认为更好的做法
始终为诸如
rails
之类的关键 gem 添加版本.
Always add version to critical gems like
rails
.
在大多数情况下坚持bundle install
(或bundle
,默认为install
).仅在确实需要并且您已为结果做好充分准备时才执行捆绑更新
.
Stick to bundle install
(or bundle
which is default to install
) in most cases. Only do bundle update
when it's really necessary and you are fully prepared for the result.
这篇关于$Bundle 安装和 $Bundle 更新之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!