-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
home: Handle empty HOME
on unix
#12023
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ehuss (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
☔ The latest upstream changes (presumably #12021) made this pull request unmergeable. Please resolve the merge conflicts. |
Can you provide some context here about why this would be changed? What is the importance of how it handles an empty HOME value? When would that happen in practice? How do other ecosystems handle this? |
|
Can you say why we wouldn't just change the docs instead?
From what I can tell, at least on my systems, that unsets the HOME variable (which should go to the fallback). As for the ecosystem question, I was asking more along the lines of what other languages and libraries do. For example, Python doesn't handle it, and it essentially becomes unusable. go also seems to fail with an empty HOME. Are there any languages or common tools or libraries that handle this? Or is this requirement a holdover from a documentation mistake when the initial I'm not completely opposed to checking for this case. However, it's a lot of code to add for an edge case that doesn't seem terribly important without some motivation. |
Hmmm. I can't find any resources on any other languages handling this. On top of that, defining @ehuss It would be nice to get your input on rust-lang/rust#71684 & rust-lang/rust#110665. |
home: fix & enhance documentation ### What does this PR try to resolve? Fixes the documentation to specify that the `HOME` environment variable will be returned on Unix even if it is empty. Also cleaned up & improved documentation in other areas. ### Additional information Related: #12023
What does this PR try to resolve?
Contrary to the documentation, if the
HOME
environment variable is empty on Unix, then an empty Path is returned. This is becausestd::env::home_dir
doesn't handle this case.I've copied the code from standard library & added a
.filter(|s| !s.is_empty())
check. The rest of the code is the same.Also added a test similar to Windows.
How should we test and review this PR?
The current
home_dir
function doesn't handle an emptyHOME
environment variable, with this PR, it should.Additional information
Related discussion: rust-lang/rust#71684 (comment)