Skip to content

Fix the crash on paths and folders that can not be read to close #788 - #810

Merged
mathiasrw merged 5 commits into
mainfrom
fix/788
Oct 23, 2026
Merged

mathiasrw merged 5 commits into
mainfrom
fix/788

Conversation

@mathiasrw

@mathiasrw mathiasrw commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Closes #788

The first PR of a new train. #789 and #790 go on top of it.

Change

  • Before, fs.statSync threw everything but ENOENT, and the run crashed with a stack trace. Now:
    • A path that is not there, or has a file where a folder should be (ENOENT, ENOTDIR), goes on to be globbed, as before.
    • A glob that can not be looked at as a path, like a long brace glob, goes on to be globbed.
    • A plain path that can not be looked at, like a name that is too long or a symlink loop, is a ❌ error for that path (exit code 2), and the run goes on with the other files. So it is not hidden as 0 files found.
  • When the glob itself fails (like a.md/x, where a.md is a file), it is an error (exit code 2), and the run goes on with the files that can be found:
> rexreplace foo bar a.md/x
 ❌ Not all paths could be accessed
    ENOTDIR: not a directory, scandir '…/a.md'

 🟡 0 files found
  • The same for the paths from --glob-pipe. A glob of --exclude-glob that fails is a panic (exit code 3), as the files it should keep out can not be known.

With Bun and Node the long brace glob from the issue now just works: the files it can find are found.

From the review of 23 October.

Tests

yarn test-ci passes: the demo on Node and Bun, and 1028 Bun tests. test/fix/788.test.js is new, and all its tests fail without the fix.

After the review of 24 October

  • A glob that meets a folder that can not be read, like one with no access, is now an error (Not all paths could be accessed: EACCES …), and the run goes on with the files that can be found. The exit code is 2, like for a file that can not be read. Before, one locked folder anywhere in '**/*.md' stopped the whole run, and no file was changed.
  • With --halt it still stops at once.
  • A glob of --exclude-glob that fails is still a panic, as the files it should keep out can not be known, and they must not be changed.
  • The title now says what is fixed.

After the review of 24 October

  • The error says Not all paths could be accessed: EACCES ….

@mathiasrw
mathiasrw marked this pull request as ready for review October 23, 2026 12:02
@mathiasrw
mathiasrw added this pull request to stack #842 October 23, 2026 13:57
@mathiasrw
mathiasrw marked this pull request as draft October 23, 2026 14:32
@mathiasrw mathiasrw changed the title Give a panic and not a stack trace when a path can not be looked at to close #788 Fix the crash on paths and folders that can not be read to close #788 Oct 23, 2026
@mathiasrw
mathiasrw marked this pull request as ready for review October 23, 2026 14:34
@mathiasrw
mathiasrw marked this pull request as draft October 23, 2026 14:39
@mathiasrw
mathiasrw marked this pull request as ready for review October 23, 2026 14:40
@mathiasrw
mathiasrw merged commit 9fcd574 into main Oct 23, 2026
7 checks passed
@mathiasrw
mathiasrw deleted the fix/788 branch October 23, 2026 16:03
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.

Give a ❌ error, not a stack trace, when a path can not be looked at

1 participant