Project

General

Profile

Bug #15649

Dir.glob regression with braces and Windows drive letters

Added by daniel-rikowski (Daniel Rikowski) 12 days ago. Updated about 3 hours ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.1p33 (2019-01-30 revision 66950) [x64-mingw32]
[ruby-core:91728]

Description

I noticed that certain glob patterns involving braces and drive letters, which did work in Ruby 2.5.3, no longer work in Ruby 2.6.1.

Assume I have a directory C:\Projects and my current directory is C:\Windows. Using IRB I can observe the following results of Dir.glob:

Patterns working in 2.6.1 and 2.5.3:

Dir['c:'] => ['c:']
Dir['c:/'] => ['c:/']
Dir['c:/projects'] => ['c:/Projects']

Patterns broken in 2.6.1 (but working in 2.5.3)

Dir['{c:}'] => ['Windows']
Dir['{c:/}'] => ['Windows/']
Dir['{c:/projects}'] => []

Some background:
I noticed this problem first in Rails, where the file modification watcher tries to glob a pattern like {c:/dir1/**/*.{rb},c:/dir2/**/*.{rb},c:/dir3/**/*.{rb}}
Due to the bug above, the code reloading feature of Rails is broken using Ruby 2.6.1 on Windows. (Because the pattern is always resolved to an empty array)

Rubies tested:

  • ruby 2.5.3p105 (2018-10-18 revision 65156) [x64-mingw32]
  • ruby 2.6.1p33 (2019-01-30 revision 66950) [x64-mingw32]

Files

0001-dir.c-fix-Dir.glob-starts-with-brace.patch (2.46 KB) 0001-dir.c-fix-Dir.glob-starts-with-brace.patch h.shirosaki (Hiroshi Shirosaki), 03/20/2019 01:32 AM

Associated revisions

Revision 0f63d961
Added by shirosaki about 3 hours ago

dir.c: fix Dir.glob starts with brace

  • dir.c (ruby_glob0): expand braces if a glob pattern starts with brace. [ruby-core:91728] [Bug #15649]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 67332
Added by shirosaki about 3 hours ago

dir.c: fix Dir.glob starts with brace

  • dir.c (ruby_glob0): expand braces if a glob pattern starts with brace. [ruby-core:91728] [Bug #15649]

History

Updated by cfis (Charlie Savage) 7 days ago

Seeing the same here. Seems like its the braces that are broken on Windows in Ruby 2.6. Rails autoloading feature combines a number of glob patterns into a string for reason, instead of passing in an array.

https://github.com/rails/rails/blob/25620f91ca0ab261fbc883763040ec58d205514e/activesupport/lib/active_support/file_update_checker.rb#L143

Note I also submitted to Rails - https://github.com/rails/rails/issues/35609.

Updated by h.shirosaki (Hiroshi Shirosaki) 1 day ago

I created a patch for the bug.

#3

Updated by Anonymous about 3 hours ago

  • Status changed from Open to Closed

Applied in changeset trunk|r67332.


dir.c: fix Dir.glob starts with brace

  • dir.c (ruby_glob0): expand braces if a glob pattern starts with brace. [ruby-core:91728] [Bug #15649]

Also available in: Atom PDF