Apache 与 Ruby - Gems Issue
我在 Ubuntu 上运行得很好,但无法在 Mac OS-X 10.6.7 上运行。
我的 Apache 配置文件经过编辑,以便它运行任何 .rb
文件。我正在使用的 ruby 脚本中有 require 'rubygems'
。
在 Ubuntu 上,我在 Apache 配置文件中添加了 SetEnv RUBYOPT rubygems
,因此我什至不需要使用 require 'rubygems'
。在我的 Mac 上,即使我需要 rubygems,它也无法加载 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过不在脚本中添加
require 'dbi'
解决了这个问题。使用require 'sqlite3'
就足够了。I solved this by not putting
require 'dbi'
in my script. Usingrequire 'sqlite3'
is enough.