skip to Main Content

I am using deployer to package a symfony application on the server. During the deploy I also need to run composer install to run important commands like bin/console. Only then the deployment can be completed. Unfortunately the deployment fails and interrupts at ‘composer install’ with the error message:

[DeployerExceptionRuntimeException (127)]
The command "cd /usr/home/xxx/public_html/sw6-staging/releases/1.1 && composer install" failed.
Exit Code: 127 (Command not found)
================
bash: line 1: composer: command not found

This is the task in the deploy.php looks:

task('sw:deploy', function(){
run('cd {{release_path}} && composer install');
});

task('deploy', [
'deploy:prepare',
'deploy:lock',
'deploy:release',
'deploy:update_code',
'sw:deploy',
])->desc('Deploy your project');

But if I run the command ‘composer install’ directly on the server via CLI it runs through. What is the problem and how can I solve it?

Deployer version 6.8.
PHP version 7.2

Thanks a lot

2

Answers


  1. I had the exact same issue. It seems that deployer connects to the server with a non-login, non-interactive shell, that doesn’t load the shell startup files like ~/.bash_profile -> ~/.bash_login -> ~/.profile.

    In my case the .bashrc had the following entry:

    PATH="$HOME/.linuxbrew/bin:$HOME/.linuxbrew/sbin:$PATH"
    

    but wether node, nor npm or composer where reachable, so obviously this file wasn’t used. Also there were no ~/.bash_profile so I created one and added the path there too:

    echo "PATH="$HOME/.linuxbrew/bin:$HOME/.linuxbrew/sbin:$PATH" > ~/.bash_profile
    

    Then I used the source command to load ~/.bash_profile before the composer install were called:

    task('sw:build', static function () {
        run('source /usr/home/username/.bash_profile && cd {{release_path}} && composer install');
    });
    
    Login or Signup to reply.
  2. Within 6.8, you can use shellCommand option to have a "login shell" (and load the shell startup files) :

    host('example.com')
        ->shellCommand('bash -ls')
    
    example.com:
      shellCommand : bash -ls
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search