Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 10, 2025

Fix glob not working on Windows

Root Cause Analysis

The issue is in packages/glob/src/internal-pattern.ts in the match() and partialMatch() methods:

  • Line 133: Pattern is converted to forward slashes (/) for minimatch on Windows
  • Lines 144/156: Item paths are normalized to backslashes (\) on Windows
  • Line 160: minimatch tries to match paths with backslashes against patterns with forward slashes, causing match failures

Implementation Plan

  • Analyze the exact issue and create minimal fix
  • Convert itemPath to forward slashes on Windows before passing to minimatch.match()
  • Ensure partialMatch() method has the same fix applied
  • Build and test the changes
  • Run existing test suite to ensure no regressions (all 74 tests passed)
  • Create a focused test case to validate the fix (5 new tests added, all passing)
  • Run security checks (CodeQL: 0 alerts)
  • Address code review feedback
  • Refactor duplicated code into helper method
  • Remove unused imports
  • Apply linting fixes
  • Final verification

Security Summary

CodeQL analysis completed with 0 alerts - no security vulnerabilities found.

Changes Made

  1. packages/glob/src/internal-pattern.ts:
    • Added private static helper method convertToMinimatchPath() to eliminate code duplication
    • Convert itemPath to forward slashes on Windows before passing to minimatch.match()
    • Convert itemPath to forward slashes on Windows in partialMatch() method
  2. .gitignore: Added .nx/ directory to exclude build cache
  3. packages/glob/tests/windows-path-matching.test.ts: Added 5 comprehensive Windows-specific tests, removed unused import, applied eslint formatting fixes
Original prompt

This section details on the original issue you should resolve

<issue_title>glob doesn't work on windows</issue_title>
<issue_description>Describe the bug
When using the @actions/glob library, it doesn't give any results when running on github's own windows runners.

To Reproduce
Steps to reproduce the behavior:
I created a minimal typescript action that reproduces this issue on windows runners: https://github.com/Jimver/glob-test/actions/runs/15453189713/job/43499917075

Expected behavior
Regardless of OS, I would expect glob to return the test file we just created.

Notes
Strangely, the globber does actually work in unit tests I wrote, see https://github.com/Jimver/glob-test/blob/main/__tests__/glob.test.ts. Though this is probably why this wasn't caught in the existing unit tests (if they run on windows). So basically the issue only manifests when running the actual action. I tried reproducing locally as well on my windows desktop but it works fine there as well.
When just using readdir directly I see the file just fine on the windows runner (see the action log debug output), so it seems to be a combination of glob and something about the windows runners which is going wrong.
</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits December 10, 2025 23:28
Co-authored-by: salmanmkc <32169182+salmanmkc@users.noreply.github.com>
…lashes

Co-authored-by: salmanmkc <32169182+salmanmkc@users.noreply.github.com>
Co-authored-by: salmanmkc <32169182+salmanmkc@users.noreply.github.com>
…ing()

Co-authored-by: salmanmkc <32169182+salmanmkc@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix glob functionality on Windows GitHub runners Fix glob pattern matching on Windows by normalizing path separators Dec 10, 2025
Copilot AI requested a review from salmanmkc December 10, 2025 23:39

// Convert to forward slashes on Windows before matching with minimatch
// since the pattern was converted to forward slashes in the constructor
if (IS_WINDOWS) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You added duplicated code? Could we refactor it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored the duplicated code into a private static helper method convertToMinimatchPath(). This method is now used in both match() and partialMatch() methods. (9de8f6f)

…lication

Co-authored-by: salmanmkc <32169182+salmanmkc@users.noreply.github.com>
@salmanmkc
Copy link
Contributor

'path' is defined but never used @copilot

Co-authored-by: salmanmkc <32169182+salmanmkc@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 11, 2025

'path' is defined but never used @copilot

Removed the unused 'path' import from the windows-path-matching test file. (f4d818c)

@salmanmkc
Copy link
Contributor

You should probably run npm linting with the fix option @copilot

Co-authored-by: salmanmkc <32169182+salmanmkc@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 11, 2025

You should probably run npm linting with the fix option @copilot

Ran npm run lint-fix which applied formatting fixes to the test file (removed trailing whitespace and reformatted long expect statements). (1cd9291)

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.

glob doesn't work on windows

2 participants