deployer: Unable to setup correct permissions for writable dirs.

Q A
Issue Type Bug
Deployer Version 4.3
Local Machine OS Windows (Running on Ubuntu 16 Laravel Homestead)
Remote Machine OS Ubuntu 14.04 Linux

Description

If you’re reporting a bug, please include following information

Steps to reproduce

dep deploy -vvv

Remote system is running on root so sudo shouldn’t be a problem.

Content of deploy.php

<?php
namespace Deployer;
require 'recipe/laravel.php';

// Configuration
set('ssh_type', 'native');
set('ssh_multiplexing', true);

set('repository', 'git@bitbucket.org:oliverkucharzewski/----api-server.git');

add('shared_files', []);
add('shared_dirs', []);

add('writable_dirs', []);

// Servers

server('production', 'manage.-.com')
    ->user('root')
    ->identityFile()
    ->set('deploy_path', '/var/www/api_server')
    ->pty(false);


// Tasks

desc('Restart PHP-FPM service');
task('php-fpm:restart', function () {
    // The user must have rights for restart service
    // /etc/sudoers: username ALL=NOPASSWD:/bin/systemctl restart php-fpm.service
    run('sudo systemctl restart php-fpm.service');
});
after('deploy:symlink', 'php-fpm:restart');

// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');

// Migrate database before symlink new release.

before('deploy:symlink', 'artisan:migrate');

Output log

With enabled option for verbose output -vvv.

vagrant@homestead:/Code/api_server$ dep deploy -vvv ➤ Executing task deploy:prepare [production] > echo $0 SSH multiplexing initialization Enter passphrase for key ‘/home/vagrant/.ssh/id_rsa’: [production] < bash [production] > if [ ! -d /var/www/api_server ]; then mkdir -p /var/www/api_server; fi [production] > if [ ! -L /var/www/api_server/current ] && [ -d /var/www/api_server/current ]; then echo true; fi [production] > cd /var/www/api_server && if [ ! -d .dep ]; then mkdir .dep; fi [production] > cd /var/www/api_server && if [ ! -d releases ]; then mkdir releases; fi [production] > cd /var/www/api_server && if [ ! -d shared ]; then mkdir shared; fi • done on [production] ✔ Ok [13s 225ms] ➤ Executing task deploy:lock [production] > if [ -f /var/www/api_server/.dep/deploy.lock ]; then echo ‘true’; fi [production] > touch /var/www/api_server/.dep/deploy.lock • done on [production] ✔ Ok [893ms] ➤ Executing task deploy:release [production] > cd /var/www/api_server && (if [ -h release ]; then echo ‘true’; fi) [production] < true [production] > cd /var/www/api_server && (rm -rf “$(readlink release)”) [production] > cd /var/www/api_server && (rm release) [production] > cd /var/www/api_server && ([ -d releases ] && [ “$(ls -A releases)” ] && echo “true” || echo “false”) [production] < false [production] > cd /var/www/api_server && (if [ -d /var/www/api_server/releases/1 ]; then echo ‘true’; fi) [production] > cd /var/www/api_server && (date +“%Y%m%d%H%M%S”) [production] < 20170320142529 [production] > cd /var/www/api_server && (echo ‘20170320142529,1’ >> .dep/releases) [production] > cd /var/www/api_server && (mkdir /var/www/api_server/releases/1) [production] > cd /var/www/api_server && (if [[ “$(man ln)” =~ “–relative” ]]; then echo “true”; fi) [production] < true [production] > cd /var/www/api_server && (ln -nfs --relative /var/www/api_server/releases/1 /var/www/api_server/release) • done on [production] ✔ Ok [4s 576ms] ➤ Executing task deploy:update_code [production] > which git [production] < /usr/bin/git [production] > /usr/bin/git version [production] < git version 2.11.0 [production] > if [ -h /var/www/api_server/release ]; then echo ‘true’; fi [production] < true [production] > readlink /var/www/api_server/release [production] < releases/1 [production] > /usr/bin/git clone --recursive -q git@bitbucket.org:oliverkucharzewski/–api-server.git /var/www/api_server/releases/1 2>&1 • done on [production] ✔ Ok [7s 971ms] ➤ Executing task deploy:shared [production] > if [ -d /var/www/api_server/shared/storage ]; then echo ‘true’; fi [production] < true [production] > rm -rf /var/www/api_server/releases/1/storage [production] > mkdir -p dirname /var/www/api_server/releases/1/storage [production] > ln -nfs --relative /var/www/api_server/shared/storage /var/www/api_server/releases/1/storage [production] > if [ -f $(echo /var/www/api_server/releases/1/.env) ]; then rm -rf /var/www/api_server/releases/1/.env; fi [production] > if [ ! -d $(echo /var/www/api_server/releases/1/.) ]; then mkdir -p /var/www/api_server/releases/1/.;fi [production] > mkdir -p /var/www/api_server/shared/. [production] > touch /var/www/api_server/shared/.env [production] > ln -nfs --relative /var/www/api_server/shared/.env /var/www/api_server/releases/1/.env • done on [production] ✔ Ok [4s 4ms] ➤ Executing task deploy:vendors [production] > if hash composer 2>/dev/null; then echo ‘true’; fi [production] < true [production] > which composer [production] < /usr/local/bin/composer [production] > which php [production] < /usr/bin/php [production] > cd /var/www/api_server/releases/1 && /usr/bin/php /usr/local/bin/composer install --verbose --prefer-dist --no-progress --no-interaction --no-dev --optimize-autoloader [production] < Generating optimized class loader [production] < The compiled class file has been removed. • done on [production] ✔ Ok [6s 878ms] ➤ Executing task deploy:writable [production] > ps axo user,comm | grep -E ‘[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx’ | grep -v root | head -1 | cut -d\ -f1 [production] < www-data [production] > cd /var/www/api_server/releases/1 && (mkdir -p bootstrap/cache storage storage/app storage/app/public storage/framework storage/framework/cache storage/framework/sessions storage/framework/views storage/logs storage) [production] > cd /var/www/api_server/releases/1 && (chmod 2>&1; true) [production] < chmod: missing operand [production] < Try ‘chmod --help’ for more information. [production] > cd /var/www/api_server/releases/1 && (if hash setfacl 2>/dev/null; then echo ‘true’; fi)

Unable to setup correct permissions for writable dirs.
You need to configure sudo’s sudoers files to not prompt for password,
or setup correct permissions manually.
➤ Executing task deploy:failed • done on [production] ✔ Ok [0ms] ➤ Executing task deploy:unlock [production] > rm -f /var/www/api_server/.dep/deploy.lock • done on [production] ✔ Ok [453ms]

[RuntimeException]
Cant’t set writable dirs with ACL.

Exception trace: () at phar:///usr/local/bin/dep/recipe/deploy/writable.php:83 Deployer{closure}() at n/a:n/a call_user_func() at phar:///usr/local/bin/dep/src/Task/Task.php:85 Deployer\Task\Task->run() at phar:///usr/local/bin/dep/src/Executor/SeriesExecutor.php:40 Deployer\Executor\SeriesExecutor->run() at phar:///usr/local/bin/dep/src/Console/TaskCommand.php:103 Deployer\Console\TaskCommand->execute() at phar:///usr/local/bin/dep/vendor/symfony/console/Command/Command.php:262 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/dep/vendor/symfony/console/Application.php:826 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/dep/src/Console/Application.php:123 Deployer\Console\Application->doRunCommand() at phar:///usr/local/bin/dep/vendor/symfony/console/Application.php:189 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/dep/vendor/symfony/console/Application.php:120 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/dep/src/Deployer.php:190 Deployer\Deployer->run() at phar:///usr/local/bin/dep/bin/dep:119 require() at /usr/local/bin/dep:4

deploy [-p|–parallel] [–no-hooks]

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Check if acl is installed: (if hash setfacl 2>/dev/null; then echo 'true'; fi)

Try this:

sudo apt-get install acl

In my case, a shared hosting without access to apt-get, I just had to change writable_mode to use chmod instead of the default acl. ->set('writable_mode', 'chmod')

Yes, this will be cool.

Actually I’m thinking about rewriting permissions system to something more reliable.

@antonmedv Is it possible to check if acl is installed and show a more helpful error message if not? If that’s not possible, I’d still suggest adjusting the error message slightly to:

Can’t set writable dirs with ACL, is ACL definitely installed?

The current error messages don’t suggest that the problem may be a missing dependency

in my case i have right config but not acl in ubuntu server

sudo apt-get install acl

Great. I found out that my ACL wasn’t installed. Yes by running it solved my issue. Thank you.

Hi every One,

If you have deploy first one with some problem (bad permission on storage, or package missed, or other, …), solve all problem, but delete current realese in deployment before restart deploy.

Hope this help you…

I have the same problem. Do you mind explaining what this line means (if hash setfacl 2>/dev/null; then echo ‘true’; fi)

I have the same problem. I have configured sudoers file to not prompt for password. I think this is still an open problem.

Try run each command on server by your self:

cd /var/www/api_server/releases/1 && (chmod 2>&1; true)
cd /var/www/api_server/releases/1 && (if hash setfacl 2>/dev/null; then echo 'true'; fi)