简体   繁体   中英

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 . Let Bundler take care of dependencies and installing for you, that's what it's there for.

Unless you're not using Bundler, you very rarely need to run gem install ... at all, actually.

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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