-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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(ext/node): homedir() getpwuid
/SHGetKnownFolderPath
fallback
#23841
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I wonder if we need to expose a similar API in deno (not for now though).
…23841) **Unix**: Returns the value of the HOME environment variable if it is set even if it is an empty string. Otherwise, it tries to determine the home directory by invoking the [getpwuid_r](https://linux.die.net/man/3/getpwuid_r) function with the UID of the current user. **Windows**: Returns the value of the USERPROFILE environment variable if it is set and it is not an empty string. Otherwise, it tries to determine the home directory by invoking the [SHGetKnownFolderPath](https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath) function with [FOLDERID_Profile](https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid). Fixes #23824
We are seeing some build failures such as this with the latest deno.
Is it related to this PR? |
@prabhu yes, it requires the
|
@littledivy, thank you for clarifying. Reading the source code for cargo home, it appears like this permission is required only for Windows. Can you correct me, if I am wrong? If sys permission isn't available, can it fallback to using the old env variable approach? |
It is also required on unix: See https://docs.rs/home/0.5.9/src/home/lib.rs.html#68-72 which calls https://doc.rust-lang.org/std/env/fn.home_dir.html. This is marked as a fix because without a generic permission |
Unix: Returns the value of the HOME environment variable if it is set even if it is an empty string. Otherwise, it tries to determine the home directory by invoking the getpwuid_r function with the UID of the current user.
Windows: Returns the value of the USERPROFILE environment variable if it is set and it is not an empty string. Otherwise, it tries to determine the home directory by invoking the SHGetKnownFolderPath function with FOLDERID_Profile.
Fixes #23824