Chmod events on OSX triggering rebuilds when I think they should be ignored

I’m running into an issue with my very large (~1k pages) project. As part of the site’s build, I copy site files (markdown, images) from disparate folders in the repo into the content folder, and then run hugo serve. When I script this, hugo serve gets stuck in a rebuild loop, triggering on CHMOD events, like so:

INFO 2022/04/11 22:18:37 Received System Events: ["<repo>/content/restaurant/orders-workflow/menu-item-search/media/service_component_diagram.png": CHMOD "<repo>/content/restaurant/orders-workflow/order-ready-communication-service/media/order-ready-communication-service.svg": CHMOD

for about every file in the content folder. I was looking through Discourse and the source, and found this hugo/hugo.go at master · gohugoio/hugo · GitHub, which seems relevant but not actually working for my usecase.

If I add a ~30 second sleep between my file manipulations and hugo serve that seems to be enough time for the events to stop. I also tried adding the content folder to the privacy list in Spotlight, as the comment mentions, but that isn’t a great solution for other users who will be building this site.

Any help would be appreciated, thanks!

Would it be feasible for you to mount the “disparate folders in the repo” to contentDir instead of copying them?

Hmm thats an interesting idea. I hadn’t considered that because I do some other pre-processing (generating frontmatter, renaming README.md → _index.md, mostly) after the files have moved. Unfortunately, the repo has grown organically and I’m trying to get Hugo introduced with as little friction as possible, which is why I’m attempting to do these things on the fly. If I were to change the files in-place, and then mount them, I’m not sure if that would create more confusion/be more complicated.

Been there, done that, not fun.

If you’re trying to sell performance as a reason to change, that’s a bit of a stretch if you’re adding a 30 second delay to every build.

We don’t trigger rebuilds on CHMOD events. We do listen to and log those events, though, and your setup doesn’t look like anything I would recommend.

Based on the hugo serve -v logs, I don’t see any other non-chmod events and a rebuild still gets triggered. See this Pastebin with the logs captured during serving.

As for not recommended, I agree, but organizational inertia is a hell of a thing.

Yea, you are right; we have a logic that detects “mass edits” (that logic also includes CHMOD) which schedules a full rebuild after 4 seconds. That logic could be changed, of course, but organizational inertia is a hell of a thing.

Does that same detection happen if hugo serve is run after the mass edit? Is Hugo just catching the tail end of the mass edits and that is enough to trigger the rebuild?

This happens when the server is running.

We by default listens to native events, but you can try the polling option:

hugo server --poll 2s

Or something.

I implemented that, but I don’t remember the details, but I do suspect that that does not raise any CHMOD events.

Or you could aquire a file lock on .hugo_build.lock.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.