Rails : gem install vs. gemfile & bundle install

爱⌒轻易说出口 提交于 2019-12-06 04:56:44

问题


What is the exact difference between using:

1- gem install [gemname]

and

2- add gem name & version to GemFile and run bundle install

?


回答1:


RubyGems is akin to a package manager for Ruby. It's a means by which you can install self-contained libraries to use in your applications. When you use gem install gemname you're installing that gem to the current machine that you're developing on.

Bundler is a tool for managing the gems that your application depends on. When you create a Gemfile, you list the various gems and their versions that your application requires. This allows you to easily ensure that your application has the gems it needs when you deploy it to a new location - for example, when you push to Heroku, your Gemfile is used to determine all the dependencies of your application.

Running bundle install will take the list of required gems in your gemfile and install them if they aren't installed already, just like doing gem install for each gem that your application needs.



来源:https://stackoverflow.com/questions/17047008/rails-gem-install-vs-gemfile-bundle-install

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!