Description
Issue Description
When running repomix on repositories that contain .gitignore files with certain backslash-escaped patterns, it fails with error during the file filtering phase.
The underlying path validation (likely from the ignore npm package) throws an error because it encounters a string it doesn't consider a valid relative path.
Steps to Reproduce
You can reproduce this by running Repomix against the following repositories:
Test Case 1: Microsoft Data Formulator
- Run
repomix --remote https://github.com/microsoft/data-formulator
Test Case 2: Claude Code (Best)
- Run
repomix --remote https://github.com/claude-code-best/claude-code
Solution Discussion
To fix this robustly, we need to look at both the Git specification and how the file-filtering library processes paths.
1. What's the real meaning of a backslash in a .gitignore definition?
According to the official Git documentation:
- A backslash (
\) is strictly used as an escape character. It is used to escape characters that would otherwise be treated as special syntax (e.g., \!, \#, \*, \?).
- To ignore a literal backslash, it must be escaped as well (
\\).
- Crucially: A backslash is never used as a directory separator in
.gitignore, even on Windows. Directory separators are always forward slashes (/).
2. How to handle this best in Repomix?
Currently, it seems Repomix (or its dependency, like ignore) is either incorrectly parsing these escaped rules as file paths, or failing when testing actual files/strings that contain backslashes.
To respect the .gitignore meaning while preventing failing with error, Repomix could implement the following:
- Sanitize Paths Before Validation: Ensure that any string passed to the path-checking/filtering utility is properly normalized to a valid relative path (using forward slashes
/).
- Graceful Degradation (Try/Catch): Wrap the file filtering check (e.g., the
.ignores() call) in a try...catch block. If a specific path or rule causes the underlying library to throw a path should be a path.relative()d string error, Repomix should log a verbose warning and safely skip that specific file/rule, rather than failing the entire packing process with error.
- Respect Escape Sequences: Ensure the internal globber or gitignore parser isn't accidentally transforming
\* or \. into malformed file paths during its traversal phase.
By implementing a fallback/catch for malformed paths, Repomix will become much more resilient to the wild variations of .gitignore files found in the open-source ecosystem.
Usage Context
Repomix CLI
Repomix Version
1.17.0
Node.js Version
v26.5.0
EDIT: Replace AI Agent crash wording. There's no crash, just fail with error. Also fixed links
Description
Issue Description
When running
repomixon repositories that contain.gitignorefiles with certain backslash-escaped patterns, it fails with error during the file filtering phase.The underlying path validation (likely from the
ignorenpm package) throws an error because it encounters a string it doesn't consider a valid relative path.Steps to Reproduce
You can reproduce this by running Repomix against the following repositories:
Test Case 1: Microsoft Data Formulator
repomix --remote https://github.com/microsoft/data-formulatorError filtering files: path should be a path.relative()d string, but got "\.\NUL"Test Case 2: Claude Code (Best)
repomix --remote https://github.com/claude-code-best/claude-codeError filtering files: path should be apath.relative()d string, but got "\*.pid.lock"Solution Discussion
To fix this robustly, we need to look at both the Git specification and how the file-filtering library processes paths.
1. What's the real meaning of a backslash in a
.gitignoredefinition?According to the official Git documentation:
\) is strictly used as an escape character. It is used to escape characters that would otherwise be treated as special syntax (e.g.,\!,\#,\*,\?).\\)..gitignore, even on Windows. Directory separators are always forward slashes (/).2. How to handle this best in Repomix?
Currently, it seems Repomix (or its dependency, like
ignore) is either incorrectly parsing these escaped rules as file paths, or failing when testing actual files/strings that contain backslashes.To respect the
.gitignoremeaning while preventing failing with error, Repomix could implement the following:/)..ignores()call) in atry...catchblock. If a specific path or rule causes the underlying library to throw apath should be a path.relative()d stringerror, Repomix should log a verbose warning and safely skip that specific file/rule, rather than failing the entire packing process with error.\*or\.into malformed file paths during its traversal phase.By implementing a fallback/catch for malformed paths, Repomix will become much more resilient to the wild variations of
.gitignorefiles found in the open-source ecosystem.Usage Context
Repomix CLI
Repomix Version
1.17.0
Node.js Version
v26.5.0
EDIT: Replace AI Agent
crashwording. There's no crash, just fail with error. Also fixed links