Apache与Ruby - Gems问题

时间:2011-05-23 18:05:18

标签: ruby apache macos

我在Ubuntu上工作很好,但是我无法在Mac OS-X 10.6.7上使用它。

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

在Ubuntu上,我在Apache配置文件中添加了SetEnv RUBYOPT rubygems,所以我甚至不需要使用require 'rubygems'。在我的Mac上,即使我需要rubygems,它也无法加载宝石。

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

我的脚本位于/ 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无法加载宝石?

1 个答案:

答案 0 :(得分:0)

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