17

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?

Jorge Castro
  • 70,934
  • 124
  • 466
  • 653
Amit
  • 253
  • 1
  • 2
  • 5

1 Answers1

21

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.

Marco Ceppi
  • 47,783
  • 30
  • 172
  • 197
  • Thanks Marco. That worked. I was trying similar but was giving ; before php, that should have also worked. COMPOSER_HOME=${app_dir} ; /usr/bin/php composer.phar install – Amit Sep 13 '13 at 05:48
  • 4
    No, the `;` won't make COMPOSER_HOME an environment variable, just a variable, You would need `export COMPOSER_HOME=${app_dir};` the export makes it an environment variable. What I've done is just set it as an environment variable for _just_ that command. – Marco Ceppi Sep 13 '13 at 12:19