即使我的应用程序使用捆绑器,我是否需要将乘客安装为常规 gem?
我正在尝试设置一个新服务器来托管 Rails 应用程序,并希望干净安装所有组件,因此我决定使用 rvm+bundler。这是我第一次设置 Rails 服务器。
我之前曾在应用程序中使用过捆绑器,并且我了解它如何管理应用程序的依赖项...但由于我安装了 Passenger 并且这是托管环境的依赖项,因此我需要在盒子本身上执行“gem install Passenger”捆绑这种依赖关系,对吗?或者我应该将乘客放入应用程序的 Gemfile 中?
Im trying to setup a new server to host a Rails app and want a clean installation of all the components so i decided to use rvm+bundler. Its my first time setting up a Rails server.
I've used bundler with an app before and I understand how it manages the App's dependencies... but since Im installing Passenger and since this is the hosting environment's dependency, I need to do a 'gem install passenger' on the box itself instead of bundling this dependency, right? Or should I be putting passenger in the Gemfile of the app ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
应用程序本身无需安装乘客(unicorn、webrick、mongrel、thin 等)即可运行,因此乘客不应该真正位于 Gemfile 中。在这种情况下,将乘客作为宝石单独安装将是正确的选择。
将 Gemfile 视为您的应用程序正在使用的 gem 的列表。 Passenger 使用您的应用程序向用户提供数据,而不是您的应用程序使用它。将来,您可能会考虑使用另一个应用程序服务器,并且您不必更改应用程序的任何部分,甚至是 Gemfile,即可进行更改。
但是,如果您的应用程序实际上在内部使用乘客特定的功能或乘客 gem 的一部分,那么您应该将其包含在内。例如,如果您使用在乘客中声明的类,那么您将依赖它,并且应该将其包含在您的 Gemfile 中。
The application itself would run without having passenger installed (unicorn, webrick, mongrel, thin, etc.), therefore passenger shouldn't really be in the Gemfile. Installing passenger as a gem separately would be the correct choice in this instance.
Look at the Gemfile as a list of the gems that your application is using. Passenger is using your application to serve data to the user, rather than your application using it. Down the road, you may consider using another application server, and you shouldn't have to change any portion of your application, even the Gemfile, to make that change.
However, if your application is actually using passenger-specific features or portions of the passenger gem internally, then you should include it. For example, if you were using a class declared in passenger, then you would be depending on it, and should include it in your Gemfile.
您应该阅读 RVM 的指南,了解如何使用Passenger with RVM。
简而言之,由于您的 Web 服务器一次只能使用一个版本的 Ruby 和一个版本的 Passenger,因此您只需要安装 Passenger 一次,但如果也为单个 gemset 安装它(因此在您的 Gemfile 中),那应该不会有什么坏处)。 Rails 也不需要加载乘客本身(即
require 'passenger'
),因此这也不是问题。(就我个人而言,我更喜欢使用
bundle install --deployment
在服务器上,以及本地 RVM)。You should read RVM's guide to using Passenger with RVM.
In short, since your web server can only use one version of Ruby and one version of Passenger at a time, you need only install Passenger once, but it shouldn't hurt if it's installed for individual gemsets as well (and thus in your Gemfile). Rails also doesn't need to load passenger itself (i.e.
require 'passenger'
), so that's not a concern either.(Personally, I prefer using
bundle install --deployment
on the server, and RVM locally).