简体   繁体   English

您是否需要为每个单独的Rails应用程序安装gem?

[英]Do you need to install a gem for each separate rails app

如标题所示,如果我在一个应用程序中使用gem(安装,添加到Gemfile等),是否还需要在新应用程序中运行gem install xxx

No. 没有。

In fact, for a modern (Rails 3+) app you should never need to run gem install (except, of course, for the initial gem install bundler rails that you need to do once), you should just add the gem to your Gemfile and then run bundle install . 实际上,对于现代(Rails 3+)应用程序,您永远不需要运行gem install (当然,对于需要执行一次的初始gem install bundler rails除外),您只需将gem添加到Gemfile中然后运行bundle install Let Bundler take care of dependencies and installing for you, that's what it's there for. 让Bundler照顾依赖性并为您安装,这就是它的目的。

Unless you're not using Bundler, you very rarely need to run gem install ... at all, actually. 除非您不使用Bundler,否则实际上很少需要运行gem install ...

More often than not, unless you're using different Rubies for each of your projects, all of your gems live in folders that get shared across all of the projects that use them. 通常,除非您为每个项目使用不同的红宝石,否则所有宝石都位于文件夹中,并在使用它们的所有项目之间共享。 If you're using rvm you can see this directory by running rvm gemdir . 如果您使用的是rvm ,则可以通过运行rvm gemdir看到该目录。

When you use Bundler, it will automatically handle loading the appropriate version of the gem in the (likely) case that you have several versions installed. 使用Bundler时,在(可能)安装了多个版本的情况下,它将自动处理加载适当版本的gem。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM