diff options
author | Lars Kanis <lars@greiz-reinsdorf.de> | 2022-12-18 21:05:54 +0100 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-12-24 23:48:47 +0900 |
commit | d0f5dc9eac78ecade459b740ed08795c8df6d129 (patch) | |
tree | 72dab3fcbff2e9deb40dbfce53268438b6bb6bd2 /spec/ruby/core/dir | |
parent | 6a55b4601a50144a4c98571a79395b85465fda7f (diff) |
Windows: Prefer USERPROFILE over HOMEPATH
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.
Still keeping HOME at first which is not used by native Windows,
but by ruby specs and by MSYS2 environment.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6992
Diffstat (limited to 'spec/ruby/core/dir')
-rw-r--r-- | spec/ruby/core/dir/home_spec.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/ruby/core/dir/home_spec.rb b/spec/ruby/core/dir/home_spec.rb index c49a18041b..cde6899df2 100644 --- a/spec/ruby/core/dir/home_spec.rb +++ b/spec/ruby/core/dir/home_spec.rb @@ -32,6 +32,23 @@ describe "Dir.home" do end end + platform_is :windows do + it "retrieves the directory from HOME, USERPROFILE, HOMEDRIVE/HOMEPATH and the WinAPI in that order" do + old_dirs = [ENV.delete('HOME'), ENV.delete('USERPROFILE'), ENV.delete('HOMEDRIVE'), ENV.delete('HOMEPATH')] + + Dir.home.should == old_dirs[1].gsub("\\", "/") + ENV['HOMEDRIVE'] = "C:" + ENV['HOMEPATH'] = "\\rubyspec\\home1" + Dir.home.should == "C:/rubyspec/home1" + ENV['USERPROFILE'] = "C:\\rubyspec\\home2" + Dir.home.should == "C:/rubyspec/home2" + ENV['HOME'] = "C:\\rubyspec\\home3" + Dir.home.should == "C:/rubyspec/home3" + ensure + ENV['HOME'], ENV['USERPROFILE'], ENV['HOMEDRIVE'], ENV['HOMEPATH'] = *old_dirs + end + end + describe "when called with the current user name" do platform_is :solaris do it "returns the named user's home directory from the user database" do |