Repository navigation
🐛 fix(dirs): raise when no home directory resolves - #589
Merged
Merged
Conversation
gaborbernat
force-pushed
the
fix/no-home
branch
4 times, most recently
from
September 26, 2026 14:27
298b467 to
0464a53
Compare
gaborbernat
enabled auto-merge (squash)
September 26, 2026 14:31
gaborbernat
force-pushed
the
fix/no-home
branch
from
September 26, 2026 14:45
0464a53 to
1197391
Compare
With HOME set to an empty string, os.path.expanduser puts the path under /, so Unix returned /.config/app and macOS returned /Library/Application Support/app, the shared site directory. With HOME unset and no passwd entry for the uid, it returns ~/... unchanged and the properties handed back relative paths such as ~/.config/app. tox-dev#578 guarded ensure_exists only. Rust's std::env::home_dir treats an empty HOME as unset, and platformdirs does the same, so the password database supplies the home. When neither gives one, each Unix and macOS directory under the home raises RuntimeError on read, where Go's os.UserHomeDir also returns an error. Site directories and absolute XDG values keep resolving. One helper expands ~ for both platforms; the tox-dev#578 check under ensure_exists stays for iOS, which still calls os.path.expanduser.
gaborbernat
force-pushed
the
fix/no-home
branch
from
September 26, 2026 14:57
1197391 to
889e9de
Compare
This was referenced Oct 16, 2026
This was referenced Oct 24, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
HOMEset to an empty string,os.path.expanduserputs the path under/, soUnix().user_config_dirreturned/.config/appand the macOSuser_data_dirreturned/Library/Application Support/app, the shared site directory. 🏠 WithHOMEunset and no password database entry for the uid, the same properties returned relative paths such as~/.config/appthat resolve against the working directory. #578 guarded onlyensure_exists.Rust's
std::env::home_dirtreats an emptyHOMEas unset, and platformdirs does the same, so the password database supplies the home. When neither gives one, each Unix and macOS directory under the home raisesRuntimeErroron read, as Go'sos.UserHomeDirreturns an error for an unset or emptyHOME. Site directories and absolute XDG values keep resolving. The~expansion for both platforms lives in one place and adds aHOMEcheck beforeos.path.expanduser; the #578 check underensure_existsstays for iOS, which callsos.path.expanduseritself.HOMEremoved or emptied, as withenv -iorsubprocessgiven a bareenv, for a uid without a password database entry, and an unsetHOMEon a Python built withoutpwd, as CPython's WASI build is. On macOSsite_runtime_direqualsuser_runtime_dirand raises with it, and theiter_*_dirshelpers raise on the user directory they yield first, except the Unixiter_runtime_dirs. Docker containers run with--userfor an unknown uid keep getting/.config/app, because runc setsHOME=/when the passwd lookup fails. An emptyHOMEwith a password database entry resolves to that entry's home.