Skip to content

Conversation

@pvdb
Copy link
Contributor

@pvdb pvdb commented Nov 22, 2025

Before removing it in #669 this draft PR (submitted as evidence only for the other PR) is intended to validate the equivalency of two approaches for determining Rake's "standard system directory" on Windows platforms, using "real life" scenarios that cannot be correctly reproduced in the unit tests.

The ultimate goal is to prove that Rake's custom Windows-specific implementation (Rake::Win32::win32_system_dir) produces identical results to Ruby's standard library approach (File.join(Dir.home, "Rake")), thereby demonstrating that the Rake-specific patch is superfluous and can be safely removed.

The Windows batch script calculates and compares the value for win32_system_dir using both approaches for the 5 scenarios also covered by the unit tests:

  1. %%HOME%% set in Windows env
  2. %%HOMEDRIVE%% and %%HOMEPATH%% set in Windows env
  3. %%APPDATA%% set in Windows env
  4. %%USERPROFILE%% set in Windows env
  5. nothing set in Windows env

... and runs it - as the win32 workflow in GitHub actions - for all Ruby versions supported on the Windows platform.

‼️ CLICK to see batch script output for "head" version of Ruby on Windows
---------------------------------------------------------------
    platform: Windows / branch: 

---------------------------------------------------------------
1/5 - %HOME% set in Windows env
---------------------------------------------------------------
[Windows] %HOME%=C:\HP
[Windows] %HOMEDRIVE%=
[Windows] %HOMEPATH%=
[Windows] %APPDATA%=
[Windows] %USERPROFILE%=

[Ruby] ENV["HOME"] = C:\HP
[Ruby] ENV["HOMEDRIVE"] = nil
[Ruby] ENV["HOMEPATH"] = nil
[Ruby] ENV["APPDATA"] = nil
[Ruby] ENV["USERPROFILE"] = nil

[Ruby] File.join(Dir.home, "Rake")   => C:/HP/Rake
[Rake] Rake::Win32::win32_system_dir => C:/HP/Rake
✅ PASS: Values match

---------------------------------------------------------------
2/5 - %HOMEDRIVE% and %HOMEPATH% set in Windows env
---------------------------------------------------------------
[Windows] %HOME%=
[Windows] %HOMEDRIVE%=C:
[Windows] %HOMEPATH%=\HP
[Windows] %APPDATA%=
[Windows] %USERPROFILE%=

[Ruby] ENV["HOME"] = C:/HP
[Ruby] ENV["HOMEDRIVE"] = C:
[Ruby] ENV["HOMEPATH"] = \HP
[Ruby] ENV["APPDATA"] = nil
[Ruby] ENV["USERPROFILE"] = nil

[Ruby] File.join(Dir.home, "Rake")   => C:/HP/Rake
[Rake] Rake::Win32::win32_system_dir => C:/HP/Rake
✅ PASS: Values match

---------------------------------------------------------------
3/5 - %APPDATA% set in Windows env
---------------------------------------------------------------
[Windows] %HOME%=
[Windows] %HOMEDRIVE%=
[Windows] %HOMEPATH%=
[Windows] %APPDATA%=C:\Documents and Settings\HP\Application Data
[Windows] %USERPROFILE%=

[Ruby] ENV["HOME"] = C:/Users/runneradmin
[Ruby] ENV["HOMEDRIVE"] = nil
[Ruby] ENV["HOMEPATH"] = nil
[Ruby] ENV["APPDATA"] = C:\Documents and Settings\HP\Application Data
[Ruby] ENV["USERPROFILE"] = nil

[Ruby] File.join(Dir.home, "Rake")   => C:/Users/runneradmin/Rake
[Rake] Rake::Win32::win32_system_dir => C:/Users/runneradmin/Rake
✅ PASS: Values match

---------------------------------------------------------------
4/5 - %USERPROFILE% set in Windows env
---------------------------------------------------------------
[Windows] %HOME%=
[Windows] %HOMEDRIVE%=
[Windows] %HOMEPATH%=
[Windows] %APPDATA%=
[Windows] %USERPROFILE%=C:\Documents and Settings\HP

[Ruby] ENV["HOME"] = C:/Documents and Settings/HP
[Ruby] ENV["HOMEDRIVE"] = nil
[Ruby] ENV["HOMEPATH"] = nil
[Ruby] ENV["APPDATA"] = nil
[Ruby] ENV["USERPROFILE"] = C:\Documents and Settings\HP

[Ruby] File.join(Dir.home, "Rake")   => C:/Documents and Settings/HP/Rake
[Rake] Rake::Win32::win32_system_dir => C:/Documents and Settings/HP/Rake
✅ PASS: Values match

---------------------------------------------------------------
5/5 - nothing set in Windows env
---------------------------------------------------------------
      Ruby *always* sets HOME [and USER for that matter]
      in *its* environment, even if these are not set in
      the Windows environment.

      https://github.com/ruby/ruby/commit/c41cefd492
---------------------------------------------------------------
[Windows] %HOME%=
[Windows] %HOMEDRIVE%=
[Windows] %HOMEPATH%=
[Windows] %APPDATA%=
[Windows] %USERPROFILE%=

[Ruby] ENV["HOME"] = C:/Users/runneradmin
[Ruby] ENV["HOMEDRIVE"] = nil
[Ruby] ENV["HOMEPATH"] = nil
[Ruby] ENV["APPDATA"] = nil
[Ruby] ENV["USERPROFILE"] = nil

[Ruby] File.join(Dir.home, "Rake")   => C:/Users/runneradmin/Rake
[Rake] Rake::Win32::win32_system_dir => C:/Users/runneradmin/Rake
✅ PASS: Values match

----------------------------------

✅ OVERALL RESULT: All tests passed

This comprehensive testing approach ensures that the removal of Rake::Win32::win32_system_dir in #669 is both safe and well-validated across the entire ecosystem of supported Ruby versions and Windows environment configurations.

Note

Once #669 has been reviewed, approved and merged, this PR can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant