Skip to content

Conversation

@majiayu000
Copy link

Fixes #643

Changes

  • Resolve symlinks using filepath.EvalSymlinks in SetWatcher so the stored file path matches what fsnotify reports
  • On macOS, /tmp is a symlink to /private/tmp, causing path mismatch in follow mode
  • Added test for symlink resolution in file watcher

On macOS, /tmp is a symlink to /private/tmp. When monitoring files
in /tmp, fsnotify reports events with the resolved real path
(/private/tmp/...), but the stored filepath was the symlinked path
(/tmp/...). This caused the path comparison in watchEvent() to fail,
preventing follow mode from detecting file changes.

Fix by resolving symlinks using filepath.EvalSymlinks() after getting
the absolute path in SetWatcher().

Fixes noborus#643

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: majiayu000 <[email protected]>
@noborus
Copy link
Owner

noborus commented Dec 31, 2025

Thank you for the pull request.

…Windows

The test was failing on Windows because file handles were not properly
released before t.TempDir() cleanup. This change:

- Uses os.MkdirTemp instead of t.TempDir to control cleanup order
- Explicitly closes watcher before document cleanup
- Calls doc.requestClose() to properly close the file handle
- Adds runtime.GC() and time.Sleep() to ensure handles are released
- Manually removes temp directory after all resources are closed

This fixes the "The process cannot access the file because it is being
used by another process" error on Windows.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@noborus
Copy link
Owner

noborus commented Jan 1, 2026

I would like to confirm whether this issue also occurs in [fsnotify/fsnotify#642].
If anyone has information about this, I would appreciate your input.

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.

Follow mode doesn't work if file is in /tmp

2 participants