-
-
Notifications
You must be signed in to change notification settings - Fork 939
Description
Environment Information
Provide at least:
- JRuby version: JRuby 9.4.13.0, no special flags or JRUBY_OPTS
- Operating system: Windows 10 Pro / Windows Server (issue affects all Windows with network share paths)
Expected Behavior
Dir[] and Dir.glob should return file listings when given Windows network share paths with forward slashes (e.g., //server/share/path/*), matching the behavior of Dir.entries and JRuby 9.4.12.0.
Reproduction script:
# test_dir.rb
# Prerequisites: Create a shared folder on Windows and put some test files in it.
# Example: Share C:\TestShare\HOME\ with some .txt files
share_path = "//#{ENV['COMPUTERNAME']}/TestShare/HOME"
puts "JRuby version: #{JRUBY_VERSION}"
puts "Ruby version: #{RUBY_VERSION}"
puts ""
puts "Testing path: #{share_path}"
puts ""
puts "=== Dir[path + '/*'] ==="
puts Dir[File.join(share_path, '*')].inspect
puts ""
puts "=== Dir.glob(path + '/*') ==="
puts Dir.glob(File.join(share_path, '*')).inspect
puts ""
puts "=== File.exist?(path) ==="
puts File.exist?(share_path)
puts ""
puts "=== File.directory?(path) ==="
puts File.directory?(share_path)
puts ""
puts "=== Dir.entries(path) ==="
puts Dir.entries(share_path).inspect
puts ""
JRuby 9.4.12.0 output (expected):
JRuby version: 9.4.12.0
Ruby version: 3.1.4
Testing path: //DESKTOP-7EC7MKH/TestShare/HOME
=== Dir[path + '/*'] ===
["//DESKTOP-7EC7MKH/TestShare/HOME/New Text Document.txt", "//DESKTOP-7EC7MKH/TestShare/HOME/test.txt"]
=== Dir.glob(path + '/*') ===
["//DESKTOP-7EC7MKH/TestShare/HOME/New Text Document.txt", "//DESKTOP-7EC7MKH/TestShare/HOME/test.txt"]
=== File.exist?(path) ===
true
=== File.directory?(path) ===
true
=== Dir.entries(path) ===
[".", "..", "New Text Document.txt", "test.txt"]
Actual Behavior
JRuby 9.4.13.0 output (broken):
JRuby version: 9.4.13.0
Ruby version: 3.1.4
Testing path: //DESKTOP-7EC7MKH/TestShare/HOME
=== Dir[path + '/*'] ===
[]
=== Dir.glob(path + '/*') ===
[]
=== File.exist?(path) ===
true
=== File.directory?(path) ===
true
=== Dir.entries(path) ===
[".", "..", "New Text Document.txt", "test.txt"]
Dir[] and Dir.glob return empty arrays for forward-slash network share paths (//server/share), while File.exist?, File.directory?, and Dir.entries still work correctly. Drive letter mapped paths (e.g., Z:/SB_JIRA_HOME/*) also work correctly.
Note: Backslash network share paths (\server\share, i.e. "\\server\share" in Ruby) still work.
Root cause analysis
This issue was introduced by commit 3cd262c ("Handle case-preserving case insensitive filesystems in Dir.glob", part of PR #8542).
The has_magic() method was changed from returning boolean to a 3-level enum. On Windows, nonMagic is set to GlobMagic.PLAIN. The new code treats any path segment containing characters (except ?, *, [, ], \) as ALPHA on Windows. It seems that this causes the code path to split // into two separate / symbols, with an empty segment in between.