Thursday, February 02, 2006
Rails Trac bug #3493 regarding broken fcgi under Apache
OK, the original posting regarding this bug report can be found here
So I quickly checked back with Trac, guess what, nobody cares. Fine, I will fix it myself. Took me a couple of hours to finally track down the offending code which has changed for the worse in the new version. makes me really angry that somebody can actually check in some code that breaks things rather than make them better.
This is the original code, which works perfectly in the action controller 1.11.0:
@@relative_url_root ||= server_software == 'apache' ? File.dirname(env["SCRIPT_NAME"].to_s).gsub(/(^\.$|^\/$)/, '') : ''
So clearly the author makes special provision for Fcgi running on Apache, can does not make assumptions about the environment the code has to run in (this is why if you use WEBrick you will not encounter this problem).
This is the code as it is currently in action controller 1.11.2, the newer version in Rails 1.0:
# Returns the path minus the web server relative installation directory.
# This method returns nil unless the web server is apache.
#@@relative_url_root ||= server_software == 'apache' ? env["SCRIPT_NAME"].to_s.sub(/\/dispatch\.(fcgi|rb|cgi)$/, '') : ''
The author is basically you that you are stuffed if the fcgi script is not called dispatch.fcgi. Brilliant ! Highlights my point in other posts that if you customise your Rails installation in any way make sure it is not a walk in the park for unwanted visitors, ugly problems like this will come back and bite you hard .
posted by David at 1:52 AM
links to this post