Hoopla!

now with extra whiz-bang!

Hoopla!

Application Error - Rails application failed to start properly

April 09, 2006 · 19 comments

Okay, I wish I could write this now and then go back in time two days, read it, and save myself a lot of hassle. I spent a lot of time trying to debug a rails installation on a shared host and it could have been so much easier.

  1. Get your Rails app working
  1. step one
Set file permissions. Do it like so: ./public needs to be set to 755
$ chmod 755 public
./public/dispatch.fcgi (or dispatch.cgi – but don’t use that!) also to 755
$ chmod 755 public/dispatch.fcgi
make sure ./public/.htaccess exists (my copy can be found at the bottom of this post) ./log and everything under it needs to be set to 766
$ chmod -R 766 log
do the same for the ./tmp directory (Rails writes session data here)
$ chmod -R 0666 tmp
#### step two Make sure you’re running in ‘development’ mode. Code errors will be displayed to the screen in this mode – but ‘production’ will just barf out on you (it’s intended to work this way). Set RAILS_ENV=’development’ in config/environment.rb if you have no other way to do this.
$ nano config/environment.rb
#### step three If the above didn’t work, look at the bottom of any of your log files. Depending what environment you’re in you may need development.log or production.log. If it gives you a handy error like ‘could not find environment.rb’ or something like that it’ll really help you figure out the problem.
$ tail -n 100 log/development.log
#### step four Get into the ruby console. Try to run a command like you would in your app like User.find_all or something similar. This will show you errors that wouln’t come up elsewhere.
$ ./script/console 
  1. step five If you’re running an app that requires a specific version of Rails but didn’t include it along with the app you’ll need to ‘freeze’ Rails into your app. This is actually quite simple – if you put the whole Rails source code into ./vendor/rails then your application will use that code instead of the stuff on your server at /usr/lib/ruby/ The way to do this is to run any of the following:
rake freeze_gems
(get the latest stable version)
rake freeze_edge
(get the cutting-edge version)
svn co -r 997 http://dev.rubyonrails.org/svn/rails/trunk
(insert revision number you want instead of 997)
  1. good luck!
### Resources: My working .htaccess file:
AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI

RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

ErrorDocument 500 /500.html

#ErrorDocument 500 "

Application error

Rails application failed to start properly"

If these steps didn’t work for you leave a comment and I’ll try to help you out. I’m a GNU guy so I don’t know much about Rails on Windows, but I’d be happy to help you avaoid the hideous, hideous Rails errors.

Also, if you’re looking at random 500 errors while working on your Dreamhost account, you’ll want to use a modified dispatch.fcgi file.

→ 19 comments Tags: