Bamboo does not pickup $HOME environment variable
Asked by dylan_millikin:

Hey guys.

Bamboo seems to ignore my system environment variables which makes some of the tasks fail (composer). I'm running Bamboo 5.6.

I'm essentialy running a "command" task in one of my builds. This runs composer for dependency management and it expects to find a $HOME env variable set.

My bamboo runs through it's own user and when I log in locally I find my env variables just fine. But when bamboo runs they seem to never be set.

I found the following : [](https://confluence.atlassian.com/display/BAMKB/Bamboo+does+not+pick+up+the+Path+environment+variable+correctly)<https://confluence.atlassian.com/display/BAMKB/Bamboo+does+not+pick+up+the+Path+environment+variable+correctly>but I don't know if it's related because I used to test run a bamboo 5.5.x with a similar setup and that worked just fine (though it was running as root.. so maybe the above does apply but I can't set HOME globally)

Any ideas how I could work around this? I'm lost as to what to do.

Thanks

<br />

**Edit:**

Ok I had an idea as this worked. realized that command tasks had an env field. So even though it's tedious I'm using that as a workaround for the moment. Can any of you confirm this is related to the bug I linked?


Answers:
author: dylan_millikin
body: Here's more information on how I solved this in the event it can help anyone:

When setting up the tasks, there's an **Environment variables** field that can be configured. You can use this to work around the issue.

Capture d'?cran 2014-09-24 ? 18.44.49.png

As you can see above, I've configured it to use /home/bamboo (my bamboo user home folder) as the $HOME env variable.

Like I mentioned in my original post. It can become quite tedious, but at least it works.

Hope it helps  
[](https://community.atlassian.com/t5/Bamboo-questions/Bamboo-does-not-pickup-HOME-environment-variable/qaq-p/17714?attachment-id=5935){#link_1169a2bfb5a9d2}  
[](/tnckb94959/attachments/tnckb94959/bamboo-questions/533/1/Capture%20d%E2%80%99%C3%A9cran%202014-09-24%20%C3%A0%2018.44.49.png){#display_1169a2bfb5a9d2_0}

comments: author: Olga
body: Thanks, Dylan.Yes, we came to this only solution as well. Having a lot of plans/jobs, the solution doesn't look god... But looks like there is no other way :(


author: Shahriyar Imanov
body: I got it solved through customer support and eventually the reason appeared to be a wrong init.d script that starts Bamboo. In my case, I had an erroneous line in my script as follows:

```
start)    echo "Starting $APP"    /bin/su -m $USER -c "cd $BASE/logs && $BASE/bin/startup.sh &> /dev/null"    ;;
```

There "-m" part was wrong. The final, solution answer from Support was as following, which solved my problem:
> Alright.. I think we have got the root cause. The reason for this behavior is that the startup script uses the
>
> ```
> /bin/su -m $USER -c
> ```
>
> Notice the "-m", This means that the environment variables are preserved. So when you change the user to "bamboo", we didn't capture the environment variables from that user but rather, we just use the variables of the user logged in. Please edit the script and remove the "-m" option. This should fix the issue with next reboot. For more information and updated script, please refer to <https://confluence.atlassian.com/display/BAMBOO/Running+Bamboo+as+a+Linux+service>
>
> Regards


author: Shahriyar Imanov
body: But this doesn't solve the REAL problem. I also use Compass SASS preprocessor and it fails as well because $LANG env var isn't picked up as well. To be honest, NONE of the system env vars are being picked.

comments: author: dylan_millikin
body: Have you found a bug report about this or not? Maybe it would be worth bringing this up. It's been a while after all.


author: Iiro Niinikoski
body: Hi,

has anyone found any proper solution for this - why is HOME lacking in Bamboo? Can someone from Atlassian comment this?


author: john livingston
body: Our bamboo script tasks also lack the HOME env var. Tilde ('\~') is available, however, with an expected value.


author: Olga
body: Hi Dylan,

could you provide more details about the workaround you use?

I have the same issue now and cam't find out how to make Composer run normally.

Thanks

comments: author: dylan_millikin
body: Added an answer to this question with my work around. Hope it helps you.


Tags: bamboo-administration