[英]Composer Environment variable missing on CodeDeploy Application
I'm integrating AWS Auto Scaling Group with Code Deploy .我正在将AWS Auto Scaling Group与Code Deploy集成。
I wrote a bash script for AfterInstall hook.我为 AfterInstall 钩子写了一个 bash 脚本。
The script executes composer update , composer dump-autoload since my code is using PHP.该脚本执行composer update , composer dump-autoload因为我的代码使用的是 PHP。
And here is the problem.这就是问题所在。 When I deploy, deployment fails with this log.
当我部署时,部署失败并显示此日志。
[RuntimeException]
[运行时异常]
The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly
必须设置 HOME 或 COMPOSER_HOME 环境变量,composer 才能正常运行
But when I get to instance via SSH and run composer it works fine.但是当我通过 SSH 访问实例并运行 composer 时,它工作正常。
How do I fix this?我该如何解决? Anyone had worked around this issue?
有人解决过这个问题吗?
Any answer will be appreciated.任何答案将不胜感激。 Thank you for your time.
感谢您的时间。
I had a similar problem using Elastic Beanstalk and i did fixed it adding an Environment variable我在使用Elastic Beanstalk时遇到了类似的问题,我确实添加了一个环境变量来修复它
You should be able to achieve this in CodeDeploy too for example on creating the application.您也应该能够在CodeDeploy中实现这一点,例如在创建应用程序时。
See also https://github.com/composer/composer/issues/4789另见https://github.com/composer/composer/issues/4789
Could you make sure the env variable is also accessible by the user you specify in the appspec file to which runs the hook script?您能否确保您在运行挂钩脚本的 appspec 文件中指定的用户也可以访问 env 变量? If you have multiple user running on the instance, env variable might not be accessible to every user depends how you set it up.
如果您有多个用户在实例上运行,则可能并非每个用户都可以访问 env 变量,这取决于您如何设置它。
I have the same concern regarding composer install using CodeDeploy.我对使用 CodeDeploy 安装 composer 也有同样的担忧。 It runs well in develop but when I ran it in production, I'm getting: [stderr] [RuntimeException] [stderr] The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly I SSH to instance and run composer and I get:
它在开发中运行良好,但是当我在生产中运行它时,我得到:[stderr] [RuntimeException] [stderr] 必须设置 HOME 或 COMPOSER_HOME 环境变量才能使 composer 正确运行我 SSH 到实例并运行 composer 和我得到:
user@server:~/httpdocs$ /opt/plesk/php/7.2/bin/php /usr/lib/plesk-9.0/composer.phar install
Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Nothing to install or update Generating optimized autoload files user@server:~/httpdocs$使用包信息加载 composer 存储库 从锁定文件安装依赖项(包括 require-dev) 无需安装或更新 生成优化的自动加载文件 user@server:~/httpdocs$
I have one ec2 instance and I deploy in 2 separate directories for stg and prod.我有一个 ec2 实例,我为 stg 和 prod 部署在 2 个单独的目录中。 codedeploy deployment error
codedeploy部署错误
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.