开发者

Apache with Ruby - Gems Issue

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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜