System.get_env("HOME") != $HOME... why?

I’m trying to call an external (python) script with System.cmd/3, and I’m seeing some strange behavior with respect to the environment variable HOME (Linux/Mac).

System.get_env("HOME") gives me /Users/mteter on my Mac. This is correct.
System.get_env("HOME") gives me /home/mteter/work/projects/webapp on my production Linux box.

Further, if I call a shell script via System.cmd/3 on my prod Linux box, the script believes $HOME is that wrong one above. Same goes for ~.

Is this normal, or am I missing something?

Does your startscript fiddle around with $HOME? What does env | grep HOME say, run in a terminal before starting the app, then starting the app and observing its behaviour and then shutting it down and trying env | grep HOME again?

1 Like

Looks like this is what you have configured for your Linux user. You can see/change it in /etc/passwd as a root, or by using usermod command

1 Like

My linux user is standard, such that when I’m at a shell and type echo $HOME, I get /home/mteter.

I just did two tests:

  1. System.get_env(), and amongst all the environment variables I see home as HOME: /home/mteter/work/projects/webapp

  2. System.cmd("bash", ["-c", "env"]), and it agrees with HOME=/home/mteter/work/projects/webapp

I’m not highly experienced with releases, but I have looked at every config file in the project. None of them appear to be defining a change of HOME.

That’s because nothing would, this would be handled by the environment that is doing the launching of the BEAM, what environment is that, how do you do it, what is $HOME inside of ‘that’ environment?

1 Like

How embarrassing. It’s my script that I call from supervisord that is setting HOME. I totally forgot that piece.


Too much going on, and I forgot that I have a separate launch script. I guess the “complexity” of the release stuff, which I haven’t yet learned, distracted me from the obvious. :slight_smile:

1 Like

It happens to us all. ^.^


That’s true. And often explaining the problem on hand to someone or like you did on forum @michael_teter actually helps track it down. We absolutely don’t mind.