HostingRails and Capistrano Permissions Mismatch

by Chadwick Wood
April 9th, 2010

I stumbled across a problem, and then a solution, today, when deploying a Rails application to HostingRails. After I deployed, I started getting Application (500) Errors on all of my pages.

After talking with support, I found out that is was because the group write permission was being turned on on my dispatch.fcgi file. Looking further though, I realized that all of my deployed files had group write turned on! So, the question was, why?

Some searching led me to this post on the HostingRails forum, which essentially says that starting with version 1.4, Capistrano turns on group write for all your files by default. Lovely.

One commenter posed this solution (which I slightly modified), which worked for me:

In deploy.rb, add the following code:

desc "Set permissions to 755, so HostingRails does not complain"
task :hostingrails_fix do
  run "chmod 755 #{deploy_to}/current/public"
  run "chmod 755 #{deploy_to}/current/public/dispatch.*"

after "deploy:symlink", :hostingrails_fix