cold_deploy Permission denied error

137 views
Skip to first unread message

newel...@gmail.com

unread,
Jan 15, 2007, 2:08:07 PM1/15/07
to Capistrano
I am attempting to use Capistrano to deploy my rails app. My
development machine and the deployment machine are both running Ubuntu.
The problems I seem to be having are related to Ubuntu's sudo
policies. I have created the appropriate user on both machines, but am
still having the following problems:

1. the :setup task was failing on the mkdir, so I modified my
standard.rb like this:

task :setup, :except => { :no_release => true } do
run <<-CMD
sudo mkdir -p -m 775 #{deploy_to} #{releases_path} #{shared_path}
#{shared_path}/system &&
sudo mkdir -p -m 777 #{shared_path}/log &&
sudo mkdir -p -m 777 #{shared_path}/pids
CMD
end

2. cap cold_deploy seems to work until it gets to the svn co command.
That fails with the following error:
** [out :: MYSERVER] svn: Can't make directory
'/var/www/MyAppName/releases/20070115185748': Permission denied

If I run the svn co command manually on my deployment server, I get the
same error. However, if I sudo svn co ..., things work correctly.
What do I need to do, to get svn to be able to create the directories
properly? Do I need to modify the source to sudo the checkout command?

I'm sure I'm missing a logical solution to both problems, but can't
seem to figure it out. I have googled extensively, but have been
unable to find any solutions.

Thanks,

Steve

Lark...@gmail.com

unread,
Feb 28, 2007, 1:25:35 AM2/28/07
to Capistrano
I'm hitting this exact series of problems trying to use 1.4.1 to
deploy to a Ubuntu 6.10 server. Did you ever get this resolved?

Mike Gunderloy
http://afreshcup.com

Cody Maggard

unread,
Feb 28, 2007, 6:02:49 PM2/28/07
to Capistrano
I'm experiencing this as well trying to deploy to Ubuntu 6.06.1 server
using Capistrano 1.4.1 and deprec 1.3.1. Any help would be greatly
appreciated.

Lark...@gmail.com

unread,
Feb 28, 2007, 7:37:30 PM2/28/07
to Capistrano
In my case, it proved to be that my deployment user lacked sufficient
permissions in the top-level folder where I was trying to put the
project. I'd love to know what permissions I *should* use, but as this
is on an internal test server I just said the heck with it and relaxed
them to 777 and all was well. No doubt there's a more elegant (or at
least more secure!) solution.

Mike Gunderloy
http://afreshcup.com

Cody Maggard

unread,
Feb 28, 2007, 7:55:49 PM2/28/07
to Capistrano
Yeah, I'd have no problem with doing that, but I was kinda put off
after watching the "one-line Rails stack" PeepCode vid they put up.
*grin*

Wonder what I'm doing wrong. I haven't tried with the version of
deprec that he used in the webcast though.

yesteray

unread,
Feb 28, 2007, 8:13:52 PM2/28/07
to Capistrano

On Jan 15, 11:08 am, "newelli...@gmail.com" <newelli...@gmail.com>
wrote:

You need to set the permissions correctly on your server.

> 1. the :setup task was failing on the mkdir, so I modified my
> standard.rb like this:
>
> task :setup, :except => { :no_release => true } do
> run <<-CMD
> sudo mkdir -p -m 775 #{deploy_to} #{releases_path} #{shared_path}
> #{shared_path}/system &&
> sudo mkdir -p -m 777 #{shared_path}/log &&
> sudo mkdir -p -m 777 #{shared_path}/pids
> CMD
> end

The first sudo mkdir sets the permissions to 775 on the
#{releases_path} directory. Read, write and execute for both root and
root's default group, and read and execute for the world.

> 2. cap cold_deploy seems to work until it gets to the svn co command.
> That fails with the following error:
> ** [out :: MYSERVER] svn: Can't make directory
> '/var/www/MyAppName/releases/20070115185748': Permission denied

This error means what it says, the svn command can't make the
directory /var/www/MyAppName/releases/20070115185748 because it
doesn't have correct permissions, because you are checking this code
out with a user that is not root, or in root's default group.

> If I run the svn co command manually on my deployment server, I get the
> same error. However, if I sudo svn co ..., things work correctly.
> What do I need to do, to get svn to be able to create the directories
> properly? Do I need to modify the source to sudo the checkout command?

Lot's of possibilities. Make the first sudo mkdir -m 777. Perform the
checkout as root. Add the user to the group that you use.

> I'm sure I'm missing a logical solution to both problems, but can't
> seem to figure it out. I have googled extensively, but have been
> unable to find any solutions.

--

Ray

yesteray

unread,
Feb 28, 2007, 8:39:44 PM2/28/07
to Capistrano

What I do:

1) Create a user www and a group www on my deployment server. This is
the same user and group as my webserver use.

2) Add the users that I use for deployment to the www group.

3) sudo chown -R www:www #[deploy_to} <= This could be added to the
setup task

Then my deployment users have proper permission to write to the
release directory.

Then, in post_symlink I do

4) sudo "chown -R www:www #{release_path}"

HTH


--

Ray

Reply all
Reply to author
Forward
0 new messages