Apache 与 Ruby - Gems Issue

发布于 2024-11-09 05:58:56 字数 1789 浏览 0 评论 0原文

我在 Ubuntu 上运行得很好,但无法在 Mac OS-X 10.6.7 上运行。

我的 Apache 配置文件经过编辑,以便它运行任何 .rb 文件。我正在使用的 ruby​​ 脚本中有 require 'rubygems'

在 Ubuntu 上,我在 Apache 配置文件中添加了 SetEnv RUBYOPT ruby​​gems,因此我什至不需要使用 require 'rubygems'。在我的 Mac 上,即使我需要 ruby​​gems,它也无法加载 gem。

在 IRB 中,它可以很好地加载 gem,我可以从命令行运行该脚本。

我的脚本位于 /Library/WebServer/Documents

Apache 错误日志显示 -

[Mon May 23 18:56:40 2011] [error] [client ::1] /Library/Ruby/Gems/1.8/gems/dbi-0.4.5/lib/dbi/utils/date.rb:57: undefined method `deprecate' for DBI::Date:Class (NoMethodError)
[Mon May 23 18:56:40 2011] [error] [client ::1] \tfrom /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
[Mon May 23 18:56:40 2011] [error] [client ::1] \tfrom /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
[Mon May 23 18:56:40 2011] [error] [client ::1] \tfrom /Library/Ruby/Gems/1.8/gems/dbi-0.4.5/lib/dbi/utils.rb:56
[Mon May 23 18:56:40 2011] [error] [client ::1] \tfrom /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
[Mon May 23 18:56:40 2011] [error] [client ::1] \tfrom /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
[Mon May 23 18:56:40 2011] [error] [client ::1] \tfrom /Library/Ruby/Gems/1.8/gems/dbi-0.4.5/lib/dbi.rb:50
[Mon May 23 18:56:40 2011] [error] [client ::1] \tfrom /Library/Ruby/Site/1.8/rubygems/custom_require.rb:58:in `gem_original_require'
[Mon May 23 18:56:40 2011] [error] [client ::1] \tfrom /Library/Ruby/Site/1.8/rubygems/custom_require.rb:58:in `require'
[Mon May 23 18:56:40 2011] [error] [client ::1] \tfrom /Library/WebServer/Documents/ruby_file.rb:6

我认为添加 require 'rubygems' 意味着将加载 gem 路径。有人知道为什么 Apache 无法加载 gem 吗?

I have this working on Ubuntu fine, but I can't get it to work on Mac OS-X 10.6.7.

My Apache config file is edited so that it runs any .rb files. The ruby script I'm using has require 'rubygems' in there.

On Ubuntu, I added SetEnv RUBYOPT rubygems in my Apache config file so I don't even need to use require 'rubygems'. On my Mac, even when I require rubygems, it can't load the gems.

In IRB, it loads the gems fine, and I can run the script from the command line OK.

My script is at /Library/WebServer/Documents

Apache error log says -

[Mon May 23 18:56:40 2011] [error] [client ::1] /Library/Ruby/Gems/1.8/gems/dbi-0.4.5/lib/dbi/utils/date.rb:57: undefined method `deprecate' for DBI::Date:Class (NoMethodError)
[Mon May 23 18:56:40 2011] [error] [client ::1] \tfrom /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
[Mon May 23 18:56:40 2011] [error] [client ::1] \tfrom /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
[Mon May 23 18:56:40 2011] [error] [client ::1] \tfrom /Library/Ruby/Gems/1.8/gems/dbi-0.4.5/lib/dbi/utils.rb:56
[Mon May 23 18:56:40 2011] [error] [client ::1] \tfrom /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
[Mon May 23 18:56:40 2011] [error] [client ::1] \tfrom /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
[Mon May 23 18:56:40 2011] [error] [client ::1] \tfrom /Library/Ruby/Gems/1.8/gems/dbi-0.4.5/lib/dbi.rb:50
[Mon May 23 18:56:40 2011] [error] [client ::1] \tfrom /Library/Ruby/Site/1.8/rubygems/custom_require.rb:58:in `gem_original_require'
[Mon May 23 18:56:40 2011] [error] [client ::1] \tfrom /Library/Ruby/Site/1.8/rubygems/custom_require.rb:58:in `require'
[Mon May 23 18:56:40 2011] [error] [client ::1] \tfrom /Library/WebServer/Documents/ruby_file.rb:6

I thought that adding require 'rubygems' meant that the gem paths would be loaded. Anyone know why Apache can't load the gems?

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

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

发布评论

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

评论(1

音盲 2024-11-16 05:58:56

我通过不在脚本中添加 require 'dbi' 解决了这个问题。使用 require 'sqlite3' 就足够了。

I solved this by not putting require 'dbi' in my script. Using require 'sqlite3' is enough.

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