In SwitchTower::SCM::Base#run_checkout Swithtower does a chmod 666 #{log}, when this is run by a different user than the person who created the file, you get a permission error.
From the chmod manual: Only the owner of a file or the super-user is permitted to change the mode of a file.
When work around this problem, the next thing I encounter is permission trouble deleting the symlink to the current version.
run "ln -nfs #{current_release} #{current_path}"
You can't change a symlink when you're not the owner, in fact, on Linux you can't even delete the symlink if you're not the owner.
As a temporary solution I tried to change the permission of the troublesome files, but when the list of files started growing I solved it by doing the following:
desc "Change permission of the project to avoid the problems with source.checkout and symlink"
task :before_update_code do
sudo "chown -R $USER #{deploy_to}"
end
desc "Set permissions on files"
task :after_symlink do
sudo "chgrp -R www #{deploy_to}"
sudo "chgrp -R www #{current_path}"
sudo "chgrp -R www-data #{shared_path}/log"
sudo "chgrp -R www-data #{shared_path}/system"
end
We're deploying from OSX to Ubuntu Breezy. FYI: Ubuntu uses a default group the same as the username. So files become user:user by default, although this is only part of the problem.