How to set environment variable before running script inside hooks/install?
30,814
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.
Related videos on Youtube
Author by
Amit
Updated on September 18, 2022Comments
-
Amit almost 2 years
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 almost 11 yearsPlease contact me (link in my profile page), I'd love to work with you on getting a symfony workflow in Ubuntu!
-
Amit almost 11 yearsSure @JorgeCastro, I will email you once my charm is complete.
-
-
Amit almost 11 yearsThanks 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
-
Michael Gundlach almost 11 yearsNo, the
;
won't make COMPOSER_HOME an environment variable, just a variable, You would needexport 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.