Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The command "readlink" failed #2440

Closed
vmato opened this issue Mar 4, 2021 · 9 comments
Closed

The command "readlink" failed #2440

vmato opened this issue Mar 4, 2021 · 9 comments

Comments

@vmato
Copy link

vmato commented Mar 4, 2021

Readlink fails since the "current" link never been created

Example Deploy.php:

<?php
namespace Deployer;

require 'recipe/laravel.php';

// Project repository
set('repository', 'git@github.com<...>');

// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', true);

// Shared files/dirs between deploys
add('shared_files', []);
add('shared_dirs', []);

// Writable dirs by web server
add('writable_dirs', []);


// Hosts

localhost()
    ->set('deploy_path', '/var/www/api');


// Main deploy task.

desc('Deploy your project');
task('deploy', [
    'deploy:prepare',
    'deploy:vendors',
    'artisan:storage:link',
    'artisan:view:cache',
    'artisan:config:cache',
]);

Output:

`# dep deploy -vvv
➤ Executing task deploy:prepare
[localhost] > echo $0
[localhost] < sh
[localhost] > if [ ! -d /var/www/api ]; then mkdir -p /var/www/api; fi
[localhost] > if [ ! -L /var/www/api/current ] && [ -d /var/www/api/current ]; then echo 'true'; fi
[localhost] > cd /var/www/api && if [ ! -d .dep ]; then mkdir .dep; fi
[localhost] > cd /var/www/api && if [ ! -d releases ]; then mkdir releases; fi
[localhost] > cd /var/www/api && if [ ! -d shared ]; then mkdir shared; fi
• done on [localhost]
✔ Ok [25ms]
➤ Executing task deploy:vendors
[localhost] > if hash unzip 2>/dev/null; then echo 'true'; fi
[localhost] < true
[localhost] > if [ -h /var/www/api/release ]; then echo 'true'; fi
[localhost] > readlink /var/www/api/current
➤ Executing task deploy:failed
• done on [localhost]
✔ Ok [0ms]
➤ Executing task deploy:unlock
[localhost] > rm -f /var/www/api/.dep/deploy.lock
• done on [localhost]
✔ Ok [6ms]

In Process.php line 250:

[Symfony\Component\Process\Exception\ProcessFailedException]
The command "readlink /var/www/api/current" failed.

Exit Code: 1(General error)

Working directory: /var/www/api_test

Output:

Error Output:

Exception trace:
at phar:///usr/local/bin/dep/vendor/symfony/process/Process.php:250
Symfony\Component\Process\Process->mustRun() at phar:///usr/local/bin/dep/src/Utility/ProcessRunner.php:56
Deployer\Utility\ProcessRunner->run() at phar:///usr/local/bin/dep/src/functions.php:301
Deployer\run() at phar:///usr/local/bin/dep/recipe/common.php:98
Deployer\Deployer::Deployer{closure}() at n/a:n/a
call_user_func() at phar:///usr/local/bin/dep/src/Configuration/Configuration.php:68
Deployer\Configuration\Configuration->get() at phar:///usr/local/bin/dep/src/functions.php:549
Deployer\get() at phar:///usr/local/bin/dep/recipe/deploy/release.php:92
Deployer\Deployer::Deployer{closure}() at n/a:n/a
call_user_func() at phar:///usr/local/bin/dep/src/Configuration/Configuration.php:68
Deployer\Configuration\Configuration->get() at phar:///usr/local/bin/dep/src/Configuration/Configuration.php:112
Deployer\Configuration\Configuration->parseCallback() at n/a:n/a
preg_replace_callback() at phar:///usr/local/bin/dep/src/Configuration/Configuration.php:98
Deployer\Configuration\Configuration->parse() at phar:///usr/local/bin/dep/src/functions.php:761
Deployer\parse() at phar:///usr/local/bin/dep/src/functions.php:286
Deployer\run() at phar:///usr/local/bin/dep/recipe/deploy/vendors.php:15
Deployer\Deployer::Deployer{closure}() at n/a:n/a
call_user_func() at phar:///usr/local/bin/dep/src/Task/Task.php:105
Deployer\Task\Task->run() at phar:///usr/local/bin/dep/src/Executor/SeriesExecutor.php:60
Deployer\Executor\SeriesExecutor->run() at phar:///usr/local/bin/dep/src/Console/TaskCommand.php:144
Deployer\Console\TaskCommand->execute() at phar:///usr/local/bin/dep/vendor/symfony/console/Command/Command.php:255
Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/dep/vendor/symfony/console/Application.php:924
Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/dep/src/Console/Application.php:133
Deployer\Console\Application->doRunCommand() at phar:///usr/local/bin/dep/vendor/symfony/console/Application.php:265
Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/dep/vendor/symfony/console/Application.php:141
Symfony\Component\Console\Application->run() at phar:///usr/local/bin/dep/src/Deployer.php:326
Deployer\Deployer::run() at phar:///usr/local/bin/dep/bin/dep:136
require() at /usr/local/bin/dep:4

deploy [-p|--parallel] [-l|--limit LIMIT] [--no-hooks] [--log LOG] [--roles ROLES] [--hosts HOSTS] [-o|--option OPTION] [--] []`

@memen45
Copy link
Contributor

memen45 commented Mar 11, 2021

Try removing the Main deploy task from your deploy.php file. I found that some tasks are not executed when using deploy from your deploy.php file. The Main deploy task is already defined in the laravel.php file (bottom), so it is duplicate anyways.

Example of the first output steps you should expect:

✔ Executing task deploy:prepare
✔ Executing task deploy:lock
✔ Executing task deploy:release
✔ Executing task deploy:update_code
✔ Executing task deploy:shared
➤ Executing task deploy:vendors

While in the recipe file, only

    'deploy:prepare',
    'deploy:vendors',

are listed as tasks, the other steps are apparently hooked in by deployer.

@vmato
Copy link
Author

vmato commented Mar 12, 2021

How should we add all our custom tasks without having the main deploy task in our deploy.php ?

@memen45
Copy link
Contributor

memen45 commented Mar 12, 2021

You can use the before('this', 'dothis'); or after('this', 'dothis'); to hook into the existing main task.

I have no idea why main task in deploy.php is not working.

@antonmedv
Copy link
Member

I believe this is not a problem, you can easily redefine deploy task in your deploy.php file.

@memen45
Copy link
Contributor

memen45 commented Mar 12, 2021

Yes you can, but a lot of the tasks are missing if deploy is in deploy.php. For example I simply copied the deploy task from magento2 recipe to the deploy.php and it resulted in a lot less tasks executing.

@antonmedv
Copy link
Member

This is strange behaviour, and looks like a bug.

@antonmedv
Copy link
Member

Actually source of error is

task('deploy', [
    'deploy:prepare',
    'deploy:vendors',
    'artisan:storage:link',
    'artisan:view:cache',
    'artisan:config:cache',
]);

You need to make a release before (via deploy:release)

@memen45
Copy link
Contributor

memen45 commented Mar 15, 2021

Why is it needed to do deploy:release in deploy.php and not inside recipes?

@antonmedv
Copy link
Member

Because you defining your own deploy task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants