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
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:but wether
node
, nornpm
orcomposer
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:Then I used the
source
command to load~/.bash_profile
before thecomposer install
were called:Within 6.8, you can use
shellCommand
option to have a "login shell" (and load the shell startup files) :