# Deployment fails with Errno 13 rmtree - it’s always permissions!

**URL:** https://discourse.roots.io/t/deployment-fails-with-errno-13-rmtree-it-s-always-permissions/6771
**Category:** trellis
**Created:** 2016-05-18T17:48:55Z
**Posts:** 8

## Post 1 by @growdigital — 2016-05-18T17:48:56Z

I’m running into a permissions problem on deployment:

```
rmtree failed: [Errno 13] Permission denied:
'/srv/www/ysgoltrewen/releases/20160425202926/web/app/plugins/sitepress-
multilingual-cms/templates/wpml-mail/language-switcher.twig'
fatal: [46.101.72.245]: FAILED! => {"changed": false, "failed": true}
```

I’ve recursively [changed the permissions](http://codex.wordpress.org/Hardening_WordPress#File_Permissions) on `/srv/www/ysgoltrewen/releases/` using the commands:

```
find ./releases -type d -exec chmod 775 {} \;
find ./releases -type f -exec chmod 644 {} \;
```

Now I get the error message:

```
rmtree failed: [Errno 13] Permission denied:
'/srv/www/ysgoltrewen/releases/20160411174508/web/app/themes/ysgoltrewen-
wp/dist/assets/img/favicon.png'
fatal: [46.101.72.245]: FAILED! => {"changed": false, "failed": true}
```

I’ve tried different variations of permissions but still no joy :frowning:

Any pointers? Am I barking up the wrong permissions tree?

---

## Post 2 by @growdigital — 2016-05-18T18:00:22Z

Strangeness, in that I’ve just checked the symlink on the `current` directory and it is pointing to the latest release:

```
current -> /srv/www/ysgoltrewen/releases/20160518175123
```

I’m confused now, I thought that any failure would halt deployment?!

---

## Post 3 by @swalkinshaw — 2016-05-18T21:47:44Z

Depends where the failure happened. Your logs didn’t include the task where it failed so it’s hard to tell.

---

## Post 4 by @growdigital — 2016-05-19T08:37:17Z

It happened at end of tasks:

```
TASK [deploy : Finalize the deploy] ********************************************
System info:
  Ansible 2.0.1.0; Darwin
  Trellis at "Fix #569 - Only skip subdomains for non-www domains"
---------------------------------------------------
rmtree failed: [Errno 13] Permission denied:
'/srv/www/ysgoltrewen/releases/20160411174508/web/app/themes/ysgoltrewen-
wp/dist/assets/img/favicon.png'
fatal: [46.101.72.245]: FAILED! => {"changed": false, "failed": true}
    to retry, use: --limit @deploy.retry

PLAY RECAP *********************************************************************
46.101.72.245 : ok=23 changed=8 unreachable=0 failed=1
localhost : ok=0 changed=0 unreachable=0 failed=0
```

Not sure if that casts any light?! Or is there a log file with more info?

---

## Post 5 by @swalkinshaw — 2016-05-21T22:02:01Z

Trellis automatically sets the correct permissions it needs. Did you ever manually change permissions on the remote server at some point (before trying to fix it as you mentioned)?

---

## Post 6 by @growdigital — 2016-05-22T19:20:29Z

Ahh, that’ll be what it is. I’m uploading some paid for plugins manually. I’ll make sure their permissions are all sorted first before doing a deployment and report back what happens. Thanks for the heads up :slight_smile:

---

## Post 7 by @discopatrick — 2016-07-04T11:40:25Z

Hi all. I’m getting the same problem at the same task:

```
TASK [deploy : Finalize the deploy] ********************************************
System info:
  Ansible 2.0.1.0; Darwin
  Trellis at "Fix #569 - Only skip subdomains for non-www domains"
---------------------------------------------------
rmtree failed: [Errno 13] Permission denied:
'/srv/www/wow/releases/20160610210723/web/wp/wp-settings.php'
fatal: [xxx.xxx.xxx.xxx]: FAILED! => {"changed": false, "failed": true}
```

(IP address blanked out by me)

The permissions are:

```
-rw-r--r-- 1 root root 11048 Jun 10 21:10 wp-settings.php
```

Isn’t this supposed to be www-data and not root? I wonder how this got changed? Possibly while I was trying to fix a problem with a previous deploy, perhaps.

It seems to be trying to remove an old deploy (20160610210723) - that is about a month ago at time of writing. I take it then that part of the deploy process is to remove old deploys beyond a certain number/timeframe?

I’m going to try fixing it by removing the dir myself.

---

## Post 8 by @growdigital — 2016-07-04T12:26:20Z

Apologies for delay, it _was_ uploading plugins manually what done it. I tried altering the permissions before uploading but still getting the error, however, everything works fine.

Error message, it works anyway, I’ll ignore it ≄ perfect solution but hey, time is short :wink:
