【问题标题】:deployer: 'composer install' - command not found部署者:'composer install' - 找不到命令
【发布时间】:2021-01-07 17:13:27
【问题描述】:

我正在使用 deployer 在服务器上打包一个 symfony 应用程序。在部署期间,我还需要运行 composer install 来运行 bin/console 等重要命令。只有这样才能完成部署。不幸的是,部署失败并在“composer install”处中断并显示错误消息:

[Deployer\Exception\RuntimeException (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

这是 deploy.php 中的任务:

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');

但是,如果我通过 CLI 在服务器上直接运行命令“composer install”,它就会运行。有什么问题,我该如何解决?

部署程序版本 6.8。 PHP 7.2 版

非常感谢

【问题讨论】:

    标签: php deployment composer-php php-deployer


    【解决方案1】:

    我遇到了完全相同的问题。似乎deployer 使用非登录、非交互式 shell 连接到服务器,它不会加载 shell 启动文件,如 ~/.bash_profile -> ~/.bash_login -> ~/.profile

    在我的情况下,.bashrc 具有以下条目:

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

    但是nodenpmcomposer 都可以访问,所以很明显这个文件没有被使用。也没有~/.bash_profile,所以我创建了一个并在那里添加了路径:

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

    然后我使用source 命令在调用composer install 之前加载~/.bash_profile

    task('sw:build', static function () {
        run('source /usr/home/username/.bash_profile && cd {{release_path}} && composer install');
    });
    

    【讨论】:

      【解决方案2】:

      在 6.8 中,您可以use shellCommand option 拥有一个“登录 shell”(并加载 shell 启动文件):

      host('example.com')
          ->shellCommand('bash -ls')
      
      example.com:
        shellCommand : bash -ls
      

      【讨论】:

        猜你喜欢
        • 2019-03-13
        • 1970-01-01
        • 2014-11-01
        • 1970-01-01
        • 2016-07-22
        • 2017-12-19
        • 1970-01-01
        • 2016-01-08
        • 2017-03-14
        相关资源
        最近更新 更多