How to set environment variable before running script inside hooks/install?
I am create a simple charm to get my symfony2 webapp from git and deploy it on ec2.
After getting the source from git, I want to run composer to resolve dependencies but I keep getting this error:
INFO juju context.go:221 worker/uniter: HOOK The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly
I am running composer using below command inside my hooks/install script
juju-log "Running composer"
/usr/bin/php composer.phar install
I also tried
juju-log "Running composer"
COMPOSER_HOME=${app_dir};/bin/bash -c "/usr/bin/php composer.phar install"
How can I set HOME or COMPOSER_HOME so that this command can be executed?
HOME
isn't set in the Juju hooks, only a few environment variables are.
You should be able to just run
COMPOSER_HOME="/path/you/want/to/be/home" php composer.phar install
which will set the environment variable before executing php.