Dispatch.cgi issue

Hello,

I’m very new to Rails. I’ve been trying to set it up on my Linux server.
The installation was smooth and painless. I followed the instructions on
the Ruby on Rails website.

So I’m running Rails 1.2.3, ruby 1.8.4 and Gem 0.9.0. I created a new
application:

rails testproject

I’m trying to use Apache instead of having to use WebBrick because my
server already uses Apache. So, it should be using dispatch.cgi via
.htaccess. When I visit the page in my browser, I get the standard
“Welcome aboard” message. But when I click “About your application’s
environment” I get “Application error
Rails application failed to start properly”. Digging into Apache’s error
log, it is complaining about Premature end of script headers. So, I did
some digging and found I should try running dispatch.cgi through the
shell. When I do, I get this:

[[email protected] public]# ./dispatch.cgi
Status: 400 Bad Request
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:404:in
to_constant_name': Anonymous modules have no name to be referenced by (ArgumentError) from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:214:inqualified_name_for’
from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:476:in
const_missing' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:117:inreset_after_dispatch’
from
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:51:in
`dispatch’
from ./dispatch.cgi:10

I’ve looked high and low and cannot find anything pointing to what the
problem might be. I should note I did try running WebBrick, and through
WebBrick everything works fine. So, it’s definitely an issue with
dispatch.cgi I just don’t know what.

Thanks in advance.

JP

Usually when I get the premature end of header error, I’ve been able to
load
up script/console and it will crash with a more robust error message
letting
me know that I’ve forgotten some code in config/environment.rb. If
you’re
not getting an error with Webrick, I’m not sure. But I’d start looking
around in config/environment.rb. It seems that any problems in that file
never make it to a non-Apache log whereas bugs in other files are
written to
the appropriate RAILS_ENV mode log file. Does that help? :confused:

RSL

Thanks Russell.

So I did a bit more digging and have found that most people with this
issue just abandon SCGI and head for FCGI and things just magically
work. Lo and behold I compiled mod_fastcgi as a DSO for Apache,
installed ruby-fcgi, fixed .htaccess and hallelujah, different error!
After digging into the development log, it was clear it was a permission
error on tmp and after fixing that I get “For security purposes, this
information is only available to local requests.”

YEY, it works!

I’m thinking I don’t even know why they bother to include SCGI since it
doesn’t work for 9.5/10 people.

Thanks for your quick reply.

JP

Russell N. wrote:

Usually when I get the premature end of header error, I’ve been able to
load
up script/console and it will crash with a more robust error message
letting
me know that I’ve forgotten some code in config/environment.rb. If
you’re
not getting an error with Webrick, I’m not sure. But I’d start looking
around in config/environment.rb. It seems that any problems in that file
never make it to a non-Apache log whereas bugs in other files are
written to
the appropriate RAILS_ENV mode log file. Does that help? :confused:

RSL

Heh. Man, I apologize for having misread your email. I thought you were
talking about dispatch.fcgi [with an “f”]. [Stupid slow-acting coffee!]
Glad
you got things working though.

RSL

I’m experiencing the same problem with my server but since i’m still
in the development stage, i prefer working with cgi mode which is more
reactive to bugs. So i want to know if there is any configuration to
write in the apache files to consider rails applications and .rb
files …

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs