<#13524 Pantsd cannot find home dir> Issue created...
# github-notifications
c
#13524 Pantsd cannot find home dir Issue created by gatesn Describe the bug I would get completely blank output and exit code 1 when running
./pants --version
I found an error in
.pants.d/pants.log
suggesting it couldn't find my home directory:
Copy code
05:22:47.21 [INFO] handling request: `--version`
05:22:47.21 [INFO] request completed: `--version`
05:22:47.21 [ERROR] Uncaught exception in nailgun handler: PyErr {
    ptype: <class 'pyo3_runtime.PanicException'>,
    pvalue: Some(
        PanicException('Could not find home dir or XDG_CACHE_HOME.'),
    ),
    ptraceback: Some(
        <traceback object at 0x7f75456b9eb0>,
    ),
}
Even manually exporting XDG_CACHE_HOME didn't work in this case. I found that pantsd is launched with hermetic_environment, meaning all environment variables are purged: pants/src/python/pants/pantsd/pants_daemon.py Line 181 in </pantsbuild/pants/commit/f04f1672a18790d18fca3b06234165a80ae8fa21|f04f167> Purged here: pants/src/python/pants/util/contextutil.py Line 57 in </pantsbuild/pants/commit/7329d6d54e7d5f54887ae3acfb528a87a29f8580|7329d6d> When I added an exception to _purge_env to allow HOME and USER env vars, all worked as expected. (USER required by getpass.getuser since my username isn't in /etc/passwd) I'm not really sure why this wouldn't also be an issue for others? Perhaps there's some other ways besides environment variables that are used to find homedir and username? Pants version Pants 2.8.0rc2 Python 3.7.6 OS RHEL 8.3 pantsbuild/pants