Replace Rake's Win32-specific logic with a 100% equivalent, pure-Ruby implementation#669
Open
pvdb wants to merge 3 commits intoruby:masterfrom
Open
Replace Rake's Win32-specific logic with a 100% equivalent, pure-Ruby implementation#669pvdb wants to merge 3 commits intoruby:masterfrom
pvdb wants to merge 3 commits intoruby:masterfrom
Conversation
pvdb
commented
Nov 22, 2025
Comment on lines
-38
to
-40
| raise Win32HomeError, | ||
| "Unable to determine home path environment variable." if | ||
| win32_shared_path.nil? or win32_shared_path.empty? |
Contributor
Author
There was a problem hiding this comment.
It is worth noting that the Win32HomeError exception is never thrown IRL, because Ruby will always set the HOME environment variable in its environment, even if it isn't set in the Windows environment the Ruby process is running in.
It has done so since Ruby 1.9.x in 2004: ruby/ruby@c41cefd492
pvdb
commented
Nov 22, 2025
Comment on lines
-50
to
-52
| assert_raises(Rake::Win32::Win32HomeError) do | ||
| Win32.win32_system_dir | ||
| end |
Contributor
Author
There was a problem hiding this comment.
As per the above comment, this test is superfluous, as the exception will never be thrown IRL.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tl;dr - replace some Win32-specific Rake logic for Windows home directory detection logic with Ruby's built-in
Dir.homemethodRake's custom Windows-specific implementation (
Rake::Win32::win32_system_dir) produces identical results to Ruby's standard library approach (File.join(Dir.home, "Rake")) for all possible scenarios it caters for, so this PR removes a whole bunch of superfluous code and corresponding tests.It is replaced with a much simpler, pure stdlib-based implementation. in a low-risk manner: Ruby's cross-platform
Dir.homehas been available since Ruby 1.9 and is the standard way to get the home directory; this change simply stops reinventing the wheel. 😃Because it's hard to use and test something that isn't there anymore 😄 I've raised an accompanying DRAFT pull request #670 that explicitly tests the equivalency of both versions against the master branch (for a variety of different scenarios) thereby demonstrating that the Rake-specific patch is superfluous and can be safely removed.