Rails:gem install vs. gemfile&捆绑安装 [英] Rails : gem install vs. gemfile & bundle install
问题描述
使用之间的确切区别是什么:
What is the exact difference between using:
1- gem install [gemname]
1- gem install [gemname]
和
2- add gem name&版本转换为GemFile并运行bundle install
2- add gem name & version to GemFile and run bundle install
?
推荐答案
RubyGems 类似于Ruby的包管理器。这是您可以安装自包含库以在您的应用程序中使用的手段。当您使用 gem install gemname
时,您正在将该gem安装到正在开发的当前计算机上。
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 是一款用于管理应用程序依赖的宝石的工具。当你创建一个Gemfile时,你可以列出你的应用程序需要的各种gem及其版本。这使您可以轻松确保您的应用程序在将它部署到新位置时具有所需的宝石 - 例如,当您推送到Heroku时,您的Gemfile将用于确定应用程序的所有依赖项。
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.
运行 bundle install
会在您的gemfile中获取所需gem列表并安装它们,如果它们尚未安装,就像为您的应用程序需要的每个gem安装
。
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.
这篇关于Rails:gem install vs. gemfile&捆绑安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!