[erlang-questions] "erlexec: HOME must be set" error - a build question

Raymond Xiong <>
Fri Jun 6 08:01:29 CEST 2008

(I guess Richard forgot to copy to the mailig list, so I reply to all)

On 06/06/08, Richard A. O'Keefe wrote:
> It's always possible to write a little C program that
> (1) Calls getuid() to find who is running it.
> (2) Calls getpwuid() to find the /etc/passwd record for that user.
> (3) Calls puts() to write the pw_dir field of that record.
> #include <unistd.h>
> #include <pwd.h>
> #include <stdio.h>
> int main(void) {
>     struct passwd *pw = getpwuid(getuid());
>     puts(pw == 0 ? "/tmp" : pw->pw_dir);
>     return 0;
> }
> Your build.ksh script can then do HOME=`homedir` and you are done.
> Almost.  There is one flaw in this, which means that HOME cannot
> in general be precisely reconstructed.  UNIX allows more than one
> logname to map to the same uid, and these lognames might have
> different home directories.  (I've known this done.)  In that
> case you will recover >A< home directory that might not be >THE<
> $HOME you started with.
Thanks for your suggestion, but I am afraid that seems a bit complex
for a build script(though I didn't realize it can be solved in that way).
I am still curious how HOME directory is used by Erlang.

> My understanding is that "env -" should be "env -i" these days.

Didn't notice this before. Thanks for the tip.

> The C code above raises the question, if the Erlang build
> needs this, why doesn't it do that itself?

More information about the erlang-questions mailing list