Feature #19244
closedWindows: USERPROFILE should be preferred over HOMEPATH
Description
Create a new local user on Windows called "testuser".
Then switch to the new user per runas:
C:\> runas /user:testuser cmd
Then in the new window:
C:\>ruby -e "p Dir.home"
"C:/WINDOWS/system32"
C:\>echo %HOMEDRIVE%
C:
C:\>echo %HOMEPATH%
\WINDOWS\system32
C:\>echo %USERPROFILE%
C:\Users\testuser
Dir.home
should return the home directory of the user.
Instead it returns C:/WINDOWS/system32
.
HOMEPATH is set to "\WINDOWS\system32" when running per "runas" session.
This directory is not writable by ordinary users, leading to errors with many ruby tools.
Also config files in the home directory are not recognized.
All versions of ruby until current master branch are affected.
Updated by larskanis (Lars Kanis) about 2 years ago
Patch is here: https://github.com/ruby/ruby/pull/6958
Updated by larskanis (Lars Kanis) almost 2 years ago
The above patch was incomplete, so that the order of the environment variables was changed in Dir.home
, but not the order in the startup phase, which sets the HOME
environment variable. This is fixed in https://github.com/ruby/ruby/pull/7033 .
In https://github.com/ruby/ruby/pull/7034 this kind of duplicated code is removed, so that only one code path is defining the order of evaluation.
Updated by nobu (Nobuyoshi Nakada) about 1 year ago
- Tracker changed from Bug to Feature
- ruby -v deleted (
ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [x64-mingw-ucrt]) - Backport deleted (
2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN)
Updated by larskanis (Lars Kanis) about 1 year ago
- Status changed from Open to Closed
Applied in changeset git|9a618b95cdee82b64257a248c31d49ae9f066fea.
[Feature #19244] Windows: Prefer USERPROFILE over HOMEPATH on startup as well