deployer
deployer copied to clipboard
Overriding the shell of the localhost doesn't work
Context
- Deployer version: 7.0.2
- Deployment OS: Alpine Linux
Description
The function runLocally depends on bash to run the command.
Bash is not installed on Alpine Linux.
I tried to override the default shell with the following code:
localhost()
->setShell('sh -s');
But it doesn't work, the function runLocally still tries to use bash.
Example
deploy.php example:
<?php
namespace Deployer;
require 'recipe/common.php';
localhost()
->setShell('sh -s');
host('prod')
->setHostname('prod_hostname')
->setRemoteUser('myuser')
->setDeployPath('/var/www/html');
task('test:runLocally', function () {
runLocally('echo test');
});
Command:
dep test:runLocally prod -v
Output:
task test:runLocally
[localhost] run echo test
[localhost] sh: bash: not found
Upvote & Fund
- We're using Polar.sh so you can upvote and help fund this issue.
- We receive the funding once the issue is completed & confirmed by you.
- Thank you in advance for helping prioritize & fund our backlog.
Additional note: using the 2nd arg of the runLocally function is not possible, because the core recipe of php deployer also uses this function, without specifying the argument.
I think it's not possible to change the shell only for the runLocally command at the moment, because the ProcessRunner is getting that config from the target host config:
https://github.com/deployphp/deployer/blob/ec2ebfc537e850c8ac390ad10a5b248ddf686856/src/Component/ProcessRunner/ProcessRunner.php#L63
Should work to change the setting on host('prod') I guess
Should work to change the setting on host('prod') I guess
It only works if both the local and remote hosts use the same shell though.
I could install the bash package before deploying as a workaround.
I think we need some config to add. Maybe local_shell?
local_shell would be great.
https://github.com/deployphp/deployer/blob/master/src/Deployer.php#L121-L126 might be a spot to use a new config