Skip to content
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

Fix and undeprecate home_dir() #132515

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

kornelski
Copy link
Contributor

@kornelski kornelski commented Nov 2, 2024

home_dir() has been deprecated for 6 years due to using HOME env var on Windows.

It's been a long time, and having a perpetually buggy and deprecated function in the standard library is not useful. I propose fixing and undeprecating it.

6 years seems more than long enough to warn users against relying on this function. The change in behavior is minor, and it's more of a bug fix than breakage. The old behavior is unlikely to be useful, and even if anybody actually needed to specifically use the non-standard HOME on Windows, they can trivially mitigate this change by reading the env var themselves.


Use of USERPROFILE is in line with the home crate: https://github.com/rust-lang/cargo/blob/37bc5f0232a0bb72dedd2c14149614fd8cdae649/crates/home/src/windows.rs#L12

The home crate uses SHGetKnownFolderPath instead of GetUserProfileDirectoryW. AFAIK it doesn't make any difference in practice, because SHGetKnownFolderPath merely adds support for more kinds of folders, including virtual (non-filesystem) folders identified by a GUID, but the specific case of FOLDERID_Profile is documented as a FIXED folder (a regular filesystem path). Just in case, I've added a note to documentation that the use of GetUserProfileDirectoryW can change.

I've used CURRENT_RUSTC_VERSION in a doccomment. replace-version-placeholder tool seems to perform a simple string replacement, so hopefully it'll get updated.

@rustbot
Copy link
Collaborator

rustbot commented Nov 2, 2024

r? @jhpratt

rustbot has assigned @jhpratt.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added O-windows Operating system: Windows S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Nov 2, 2024
@rust-log-analyzer

This comment has been minimized.

@jhpratt
Copy link
Member

jhpratt commented Nov 2, 2024

This is a question for @rust-lang/libs-api (or T-libs? not sure). Implementation-wise I don't see anything wrong, so r=me if the team wants it.

@jhpratt jhpratt added S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 2, 2024
@joshtriplett joshtriplett added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Nov 2, 2024
@joshtriplett
Copy link
Member

I think this is completely reasonable, and having a useful function for this in the standard library is appealing. Let's see if we have consensus to update it.

@rfcbot merge

@rfcbot
Copy link

rfcbot commented Nov 2, 2024

Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Nov 2, 2024
@rust-log-analyzer

This comment has been minimized.

library/std/src/env.rs Outdated Show resolved Hide resolved
@joshtriplett joshtriplett added the relnotes Marks issues that should be documented in the release notes of the next release. label Nov 5, 2024
@Amanieu Amanieu added S-waiting-on-fcp Status: PR is in FCP and is awaiting for FCP to complete. and removed S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). labels Nov 12, 2024
@dtolnay dtolnay added the S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). label Nov 12, 2024
@Amanieu Amanieu removed the S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. O-windows Operating system: Windows proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-fcp Status: PR is in FCP and is awaiting for FCP to complete. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants