Ups and Downs with Capistrano

Post by: on March 04, 2008 | 0 Comment

Capistrano is an insanely useful deployment system for Rails (among other things). But I just spent two hours banging against an annoying issue.After Cap extracts the latest code from my source repo (hg), it tries to set the group permissions on the files. Due to some oddness in the setup on my server this fails, even though they already have g+w set on them. It was outputting this:* executing "chmod -R g+w /wwwDocs/foo/releases/20080303233346"And then listing a series of files with “Operation not permitted”. At least I had the benefit of this output. Some stories I ready involved FastCGI failing silently after the permissions changed. Man. I got lucky.Some quick googling led me to a number of stories mentioning that cap is running “set_permissions” after the code update, and that overriding it like so will stop it from doing that:task :set_permissions, :except => { :no_release => true } do # do nothingendHowever, that had zero effect. I tried many different permutations. Once I finally dug into the actual cap recipes file (which I should have done earlier), I discovered that in my (apparently newer [2.2.0]) version of capistrano, they helpfully moved the activation of this code to a flag task :finalize_update, :except => { :no_release => true } do run "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)So, I set that flag and all was finally well. Too bad there is so much info out there that’s misleading. It’s not the fault of the people who posted it, they were being helpful at the time. Anyway, I hope this post helps some other people out of the same jam.

Categories:Uncategorized