Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: File watching during zola serve failing with Zola 19.2 on macOS 14.6.1 #2663

Closed
jamiedumont opened this issue Oct 5, 2024 · 4 comments

Comments

@jamiedumont
Copy link

jamiedumont commented Oct 5, 2024

Bug Report

Environment

Zola version: 19.2
macOS: Sonoma 14.6.1

Expected Behavior

File watching and live reload should detect file changes, rebuilding and reloading site whilst zola serve is running

Current Behavior

zola serve behaves as expected with a new Zola project but not with existing projects. This behaviour was noted in 19.1 but remained after upgrading to 19.2. It would appear that file changes aren't being detected as nothing appears in terminal running command.

Step to reproduce

The watcher stops working after adding some files to a new Zola project. I've tried to pin point which files, tags, etc cause it to fail; but it's quite inconsistent. From a new project, adding something like a CSS file to static works, with changes detected. Adding an index.html to templates is detected in the first instance, but edits to that file aren't. Once the issue kicks in, changes in previously working files (like CSS in my example) aren't detected. The only way to return to a working state is to discard all changes with git.

I've been experiencing this for a number of weeks and working around it by restarting zola serve to view changes. I can't believe others will have been experiencing this without reporting it, so it must be specific to my environment and install.

I'll continue to test — perhaps removing Zola from my computer and reinstalling.


EDIT — Dropping back to v18 and everything works as expected. Testing various versions I've been able to determine that — in my environment at least — this bug was introduced with v19.0. This PR
seems the most likely change.

I'll pull down main and start pulling it apart to work out where the issue is on Monday.

@jamiedumont
Copy link
Author

jamiedumont commented Oct 5, 2024

Solved my own issue.

Worked out that my editor — Nova on macOS — is creating temporary files, which is failing the check fn is_temp_file() in file /src/fs_utils.rs at line 190. Sublime Text works correctly.

I'll dig into exactly which bit of is_temp_file() is an issue with Nova, and report back.

Very niche bug as it's both dependent on Zola version — > 18.0 — and Nova; although other editors may be an issue too.

@jamiedumont
Copy link
Author

Turns out that when Nova 11.10 is saving changes to an existing file, notify_debouncer_full is reporting the change as EventKind::Modify(ModifyKind::Name(RenameMode::Any)) whereas other editors (Sublime in this case) create a EventKind::Modify(ModifyKind::Data(DataChange::Content)).

This meant that these events were being filtered out in fn get_relevant_event_kind(event_kind: &EventKind) -> Option<SimpleFileSystemEventKind>.

Adding a match for the RenameMode::Any case fixes the issue, but I'm unsure whether this is a good idea as the event doesn't correlate with what's actually happening. My feeling is that it's a bug/choice from Panic in how Nova saves files — I'll contact them for their thoughts.

I'm happy to create a PR, but in my case I could also just use a different editor. Thoughts?

@Keats
Copy link
Collaborator

Keats commented Oct 6, 2024

You can probably add that event to the match and try editing files in sublime/emacs/vim to see if we get unrelated events

@jamiedumont
Copy link
Author

Opened a PR, and all checks passed. Let me know if you require any further changes.

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

No branches or pull requests

3 participants
@Keats @jamiedumont and others