pyenv / pyenv-installer

This tool is used to install `pyenv` and friends.
MIT License
3.96k stars 428 forks source link

Handle the case when HOME is not set in cloud-init #146

Closed marcospgp closed 1 year ago

marcospgp commented 1 year ago

I'm installing pyenv in a cloud-init config file, which runs in a context that has no $HOME env variable.

It seems pyenv installation relies on this value, and if it is not set, fails silently (installs .pyenv directory into / the root directory).

marcospgp commented 1 year ago

@native-api Whoops, my bad for calling with curl https://pyenv.run | (set -euxo pipefail && bash).

Updated PR, can you review?

native-api commented 1 year ago

Maybe it's easier to just check for HOME specifically?

Since we don't require the same for any other variables.

native-api commented 1 year ago

${HOME:-?}

marcospgp commented 1 year ago

@native-api good point, only $HOME seems to cause a bug if unset. Updated PR

native-api commented 1 year ago

Since we only (currently) need HOME if the install location is not specificed explicitly via PYENV_ROOT, I moved the test there.

Is that okay?

derek-olds commented 1 year ago

This seems like it could default to /opt without causing problems. Is there a reason that it doesn't get pushed there on install? I know I was surprised to find it in home when I didn't set PYENV_ROOT.