简体   繁体   中英

Composer Environment variable missing on CodeDeploy Application

I'm integrating AWS Auto Scaling Group with Code Deploy .

I wrote a bash script for AfterInstall hook.

The script executes composer update , composer dump-autoload since my code is using 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

But when I get to instance via SSH and run composer it works fine.

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

在此处输入图像描述

在此处输入图像描述

You should be able to achieve this in CodeDeploy too for example on creating the application.

在此处输入图像描述

See also 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? If you have multiple user running on the instance, env variable might not be accessible to every user depends how you set it up.

I have the same concern regarding composer install using CodeDeploy. 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:

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$

I have one ec2 instance and I deploy in 2 separate directories for stg and prod. codedeploy deployment error

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM