basho / node_package

RPM/Debian/FreeBSD/SmartOS/Solaris/OSX packaging templates for Erlang Nodes
Apache License 2.0
89 stars 63 forks source link

Setting HOME env variable when unset due to downstream failures [JIRA: TOOLS-138] #185

Closed drewkerrigan closed 8 years ago

drewkerrigan commented 9 years ago

Related issue here: https://github.com/basho/cuttlefish/issues/193

"erlexec requires the HOME variable to be set.

sargun@ubuntu:/tmp/mesos/slaves/20150712-141616-35725601-5050-4054-S0/frameworks/riak-mesos-go3/executors/test-cluster-c16260e2-21d0-44f3-9139-59b3b0a05948-2465/runs/latest$ unset HOME
sargun@ubuntu:/tmp/mesos/slaves/20150712-141616-35725601-5050-4054-S0/frameworks/riak-mesos-go3/executors/test-cluster-c16260e2-21d0-44f3-9139-59b3b0a05948-2465/runs/latest/riak/bin$ ./riak config generate -l debug
erlexec: HOME must be set

The way that this manifests itself during normal Riak startups, if $HOME isn't set:

=====
===== LOGGING STARTED Sun Jul 12 14:36:54 PDT 2015
=====
erlexec: HOME must be set
Error generating config with cuttlefish
  run `riak config generate -l debug` for more information.

Can we automatically set $HOME, if it's not set already?"

I've addressed this with the following addition to env.sh:

# erlexec requires HOME to be set. The username needs to be a
# unquoted literal because of the tilde expansion, hence the
# usage of eval.
if [ -z "$HOME" ]; then
    export HOME=`eval echo "~$WHOAMI"`
fi
jonmeredith commented 9 years ago

Silly shells.

Would you mind using 'id -un' instead of whoami as I'm not sure whoami is IEEE1003.2/POSIX.2 (but don't have a copy of it handy to be sure).

randysecrist commented 9 years ago

@jonmeredith looks like WHOAMI is used in a few spots. Are you thinking about comprehensive change, or just for the localized to the HOME var?

macintux commented 9 years ago

POSIX.2 is reportedly very similar to the Single UNIX Specification, where it appears who am i is specified but whoami is not.

http://pubs.opengroup.org/onlinepubs/007908799/

jonmeredith commented 9 years ago

Haha, teach me to look at just the diff and put my foot in it. If we're using whoami in other places successfully on our platforms I'm less concerned. Ideally we'd standardize on SUS/POSIX.2 commands.

sargun commented 9 years ago

Just curious, do we write to $HOME, anywhere in the code?

drewkerrigan commented 9 years ago

@jonmeredith whoami has been used for quite some time in this script. I agree it should probably be changed to id -un, but perhaps for another PR, like this one: https://github.com/basho/node_package/pull/186 :-)

@sargun I wasn't able to find any other places writing to the HOME env variable in the release code for Riak anyway, nor did I find anything reading from it. I think erlexec is the primary piece that requires it, which is used in a few of the scripts generated by this repo and rebar.

DSomogyi commented 9 years ago

create jira issue

Basho-JIRA commented 9 years ago

Can this be prioritized in the next set of DevOps work?

_[posted via JIRA by Derek Somogyi]_

Basho-JIRA commented 8 years ago

this is merged [where is the close ticket button?]

_[posted via JIRA by David Andersen]_