views:

66

answers:

2

Hello!

I have configured my Apache installation to run Ruby CGI scripts. I am now trying to run a simple Ruby CGI script that requires a gem.

When I run this script from the command line, it outputs correctly. But when I call it as an Apache CGI script, it generates an Apache Internal Server Error. The script looks like this:

#!/Ruby/bin/ruby

require 'RedCloth'  # <-- This is the gem

puts "Content-type: text/html"
puts 
puts
puts "<html>"
puts "<head>"
puts "</head>"
puts "<body>"
puts "I want to call a gem."
puts "</body>"
puts "</html>"

The Apache error log shows these lines:

C:/Ruby/lib/ruby/1.9.1/rubygems/config_file.rb:56:in `join': can't convert nil into String (TypeError)
[error] [client 127.0.0.1] \tfrom C:/Ruby/lib/ruby/1.9.1/rubygems/config_file.rb:56:in `<class:ConfigFile>'
[error] [client 127.0.0.1] \tfrom C:/Ruby/lib/ruby/1.9.1/rubygems/config_file.rb:28:in `<top (required)>'
[error] [client 127.0.0.1] \tfrom <internal:lib/rubygems/custom_require>:29:in `require'
[error] [client 127.0.0.1] \tfrom <internal:lib/rubygems/custom_require>:29:in `require'
[error] [client 127.0.0.1] \tfrom C:/Ruby/lib/ruby/1.9.1/rubygems.rb:1110:in `<top (required)>'
[error] [client 127.0.0.1] \tfrom <internal:lib/rubygems/custom_require>:29:in `require'
[error] [client 127.0.0.1] \tfrom <internal:lib/rubygems/custom_require>:29:in `require'
[error] [client 127.0.0.1] \tfrom <internal:gem_prelude>:167:in `load_full_rubygems_library'
[error] [client 127.0.0.1] \tfrom <internal:gem_prelude>:217:in `try_activate'
[error] [client 127.0.0.1] \tfrom <internal:lib/rubygems/custom_require>:32:in `rescue in require'
[error] [client 127.0.0.1] \tfrom <internal:lib/rubygems/custom_require>:29:in `require'
[error] [client 127.0.0.1] \tfrom C:/Apache/Apache2.2/cgi-bin/cgitest.rb:3:in `<main>'

When I don't include the require 'RedCloth' line, Apache executes my cgi script just fine.

Is there someting obvious that I'm missing here? Can you, in fact, even execute a Ruby CGI script that requires a gem? Any insights would be greatly appreciated.

Thanks, Maurice

A: 

Have you try this ? require 'rubygems' require 'RedCloth' # <-- This is the gem

germanlinux
Oh yes, I've done that. Apache definitely does not process *anything* that is a gem. If I require one of the standard Ruby libraries like 'cgi' or 'test/unit', Apache executes the script just fine.
yoshida27
A: 

probably running as apache it doesn't have "read" access to some file or other

rogerdpack