Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
320 views
in Technique[技术] by (71.8m points)

ruby on rails - Difference between $Bundle install and $Bundle update

Could you tell me, whats the difference between:

$Bundle update

and

$Bundle install
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:

  1. If the gems specified in Gemfile don't have version, it will upgrade to whatever latest.
  2. 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 if 2.2.6 is the newest, it won't do anything.

Better practice in my opinion

  1. Always add version to critical gems like rails.

  2. 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...