Work around EPERM fstat error for inotify under WSL #6535
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
fstat
system call raises EPERM when run against an inotify file descriptor under Windows Subsystem for Linux, as reported in #6129.Rails uses inotify support via rb-inotify, which recently started using
IO.new
to wrap the inotify file descriptor. Our logic forIO.new
tries to usefstat
in two places, which causes rb-inotify to fail.There are updates to WSL that purport to improve inotify support, but I have been unable to find a rig that works properly.
This PR makes the following changes in an attempt to deal with the issue:
fcntl
except on Windows (which only hasfstat
). This means we usefcntl
under WSL, avoiding the EPERM.fstat
to determine the file type, which we do to skip using selection logic against normal files. The logic I added assumes if we can'tfstat
it is probably not a normal file.The second fix is mildly hacky but our fstat there was already hacky.
This allows the reduced script from #6129 to run properly and may fix #6129 sufficiently well.