Rails/Passenger:没有要加载的文件——金钱(MissingSourceFile)

发布于 2024-09-17 23:11:44 字数 1512 浏览 13 评论 0原文

我正在尝试将 Rails 应用程序(在开发中运行良好)部署到生产服务器上。我已经安装并配置了 Apache、Passenger 和必要的 gem。重新启动 apache 并导航到服务器后,出现以下错误:

Exception PhusionPassenger::UnknownError in PhusionPassenger::Railz::ApplicationSpawner (no such file to load -- money (MissingSourceFile))

gem list Money 显示:

*** LOCAL GEMS ***

money (3.0.5)

服务器上的 irb 会话:

irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'money'
=> true

中需要 gem config/environment.rb

require 'money'

这里发生了什么?

编辑: gem 是以 root 身份安装的:

# ls -l /usr/lib/ruby/gems/1.8/gems/money-3.0.5/lib
total 8
drwx------ 2 root root 4096 Sep  2 10:26 money
-rw-r--r-- 1 root root 1284 Sep  2 10:26 money.rb

编辑 2: 在克服这个障碍没有成功之后,我意识到 Passenger 是为了与 Ruby Enterprise Edition 一起使用而设计的,所以我尝试安装它。之后,我使用 Ruby Enterprise 版本的 gem 安装了所有必需的 gem。现在,当我重新启动 apache 并导航到我的服务器时,我得到:

Exception LoadError in PhusionPassenger::Railz::ApplicationSpawner (no such file to load -- logger)

我在旧版本或新版本的 Ruby 中要求记录器都没有问题:

# which irb
/usr/bin/irb
# irb
irb(main):001:0> require 'logger'
=> true
irb(main):002:0> exit
# /opt/ruby-enterprise-1.8.7-2010.02/bin/irb 
irb(main):001:0> require 'logger'
=> true

路径或权限一定有问题,但我遵循了 Passenger 和完全是 Ruby 企业版安装程序。还有其他想法吗?

I am attempting to deploy a Rails application (which works fine in development) onto a production server. I have installed and configured Apache, Passenger, and the necessary gems. After I restart apache and navigate to the server, I get the following error:

Exception PhusionPassenger::UnknownError in PhusionPassenger::Railz::ApplicationSpawner (no such file to load -- money (MissingSourceFile))

gem list money shows:

*** LOCAL GEMS ***

money (3.0.5)

An irb session on the server:

irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'money'
=> true

The gem is required in config/environment.rb:

require 'money'

What's going on here?

Edit: The gem was installed as root:

# ls -l /usr/lib/ruby/gems/1.8/gems/money-3.0.5/lib
total 8
drwx------ 2 root root 4096 Sep  2 10:26 money
-rw-r--r-- 1 root root 1284 Sep  2 10:26 money.rb

Edit 2: After having no success with that roadblock, I realized that Passenger is sort of made to go along with Ruby Enterprise Edition, so I tried installing that. Afterwards, I used Ruby Enterprise's version of gem to install all the required gems. Now when I restart apache and navigate to my server, I get:

Exception LoadError in PhusionPassenger::Railz::ApplicationSpawner (no such file to load -- logger)

I have no problem requiring logger in either the old or new versions of Ruby:

# which irb
/usr/bin/irb
# irb
irb(main):001:0> require 'logger'
=> true
irb(main):002:0> exit
# /opt/ruby-enterprise-1.8.7-2010.02/bin/irb 
irb(main):001:0> require 'logger'
=> true

Something must be going on with paths or permissions, but I followed the instructions in both the Passenger and Ruby Enterprise Edition installers exactly. Any other ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

寂寞笑我太脆弱 2024-09-24 23:11:44

Apache/Passenger 以 root(或 www-data)身份运行 ruby​​ 进程,请确保您没有将 Gem 安装在本地存储库中。

在安装 gem 之前,您可能需要成为超级用户。


答案2:

require一个Gem的正确方法不是使用require,而是使用

config.gem "money"

Apache/Passenger runs the ruby process as root (or www-data), make sure you didn't install the Gem in a local repository.

You probably need to become superuser before installing the gem.


Answer 2:

The correct way to require a Gem is not using require, but using

config.gem "money"
我乃一代侩神 2024-09-24 23:11:44

你两者都使用相同版本的 ruby​​ 吗?

are you using the same version of ruby for both?

关于从前 2024-09-24 23:11:44

感谢大家的帮助。我们进行了更多调查,发现一些必需的文件(我相信是 gem 本身)是以错误的权限安装的(运行 Apache/Passenger 的用户无法读取)。我不确定为什么会发生这种情况,因为它们是以 root 身份以正常方式安装的(也许是一些非标准的 umask 问题?),但更改这些文件的权限解决了问题。

Thanks all for your help. We investigated some more and found some of the required files (the gems themselves, I believe) were installed with the wrong permissions (not readable by the user that runs Apache/Passenger). I'm not sure why that happened, as they were installed the normal way as root (maybe some non-standard umask was the issue?), but changing permissions on those files fixed the problem.

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