Live preview - Rebuild failed

Running hugo -D server --disableFastRender on Fedora 31.

Very frequently when I make changes, Hugo gives an error similar to:

Rebuild failed:
Process: loading templates: walk: Readdir: decorate: lstat /bulk/tmp/quickstart/themes/september/layouts/partials/jv@phoenix.squirrel.nl.1048540:1590046260: no such file or directory
Hugo Static Site Generator v0.71.1-A301F6B2/extended linux/amd64 BuildDate: 2020-05-25T09:18:12Z

I need to restart hugo, or create this directory manually.
Any ideas what I can do to avoid this?

Please include a link to the source code repository of your project.

Sorry, no source code repository yet.

I’ve uploaded a minimal project to https://www.squirrel.nl/pub/xfer/uploads/3CsjUz7zukxBD9hq1wCBg-tA.zip.

Unpack it in an empty directory.
Start the hugo server
In a browser visit http://localhost:1313
On the landing page, click the top-left icon to go to the home page.
On the home page, click the top-right icon to go to the hers page.
In an external editor visit content/home/index.md.
Make some changes and save. Repeat.
On my system after a couple of changes the error page is displayed.

I hope you can reproduce this.
My hugo is Hugo Static Site Generator v0.71.1-A301F6B2/extended linux/amd64 BuildDate: 2020-05-25T09:18:12Z
My system is Fedora 31. Browser is Firefox 76.

Which code editor are you using?

Emacs.

Emacs’s backup file handling? (It renames the file to file~ and creates a new file)

See https://discourse.gohugo.io/t/unhelpful-error/20670/3.

1 Like

I’m not sure if this is the case here but several tools that use inotify file watching have occasional problems with Emacs. I’ll see if I can tackle this from the Emacs side.

Thanks for figuring this out.

I suspect you have an editor that writes very temporary temp files which it then deletes. Hugo should admittedly handle that situation (I think we mostly ignore “file not found” errors), but that filename looks very odd, so I would have a look at your editor or whatever setup and see what that does.

When Emacs is editing a file, say foo.txt, it creates temporary files #foo.txt# and .#foo.txt (which is a symlink to something similar to jv@phoenix.squirrel.nl.1222240:1590046260). These are auto-save and lock files.
When the file is saved for the first time the original file is renamed to foo.txt~ and the new content is written to a new file foo.txt.

This behaviour is long standing (30 years or so…) and is not easy to modify from the Emacs’ side. Also, other tools make use of this behaviour.

So the best option would be if hugo ignores these files completely. Or to add a config setting with patterns of files to be ignored.

1 Like

It looks like there have been a couple of attempts to address this in the past:

Unless I totally misunderstand the code to ignore these files should already be functional?

I can reproduce the problem. From the root of your site:

In terminal #1:

hugo server

In terminal #2:

touch "$HOME/target.md"
mkdir "content/foo"                             # Change detected
ln -s "$HOME/target.md" "content/foo/#bar.md#"  # Change not detected
rm "$HOME/target.md"                            # Change not detected

Now we have a broken symlink remaining in content/foo.

In terminal #1:

Ctrl + C
hugo server

Result:

Error: Error building site: process: readAndProcessContent: walk: Readdir: decorate: lstat /home/jmooring/target.md: no such file or directory

Summary:

It looks like we ignore the emacs files in some contexts, but not in others. Log an issue on GitHub.

Thank you! So it is not just me…

1 Like