即使我的应用程序使用捆绑器,我是否需要将乘客安装为常规 gem?

发布于 2024-10-20 22:05:39 字数 238 浏览 3 评论 0原文

我正在尝试设置一个新服务器来托管 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

皇甫轩 2024-10-27 22:05:39

应用程序本身无需安装乘客(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.

屋檐 2024-10-27 22:05:39

您应该阅读 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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文