Hugo: EOF error when "static" directory is empty

Created on 3 Feb 2019  ·  9Comments  ·  Source: gohugoio/hugo

  • hugo version:
    Hugo Static Site Generator v0.54.0/extended darwin/amd64 BuildDate: unknown (installed via Homebrew)
  • Steps to reproduce:

    1. Create a site folder with an empty static directory.

    2. Run hugo.

  • Observed result:
    Output resembling the following:
    Total in 215 ms Error: Error copying static files: EOF
    The list of total files generated does not display. Files generate and build into the default destination directory as expected.
  • Expected result:
    Output resembling the following:

    
                     | EN
    +------------------+----+
    Pages            | 13
    Paginator pages  |  0
    Non-page files   |  0
    Static files     |  0
    Processed images |  0
    Aliases          |  0
    Sitemaps         |  1
    Cleaned          |  0
    
    Total in 209 ms
    

    This was the behavior previously observed with my test case in 0.53.0, and the behavior observed when the empty "static" directory is deleted or a file is added to it (with the addition of that blank file being notated in the list of generated files).

  • Other observations:
    This also affects hugo server; namely, preventing it from running entirely. In order to get hugo server to run, either the empty "static" directory needs to be deleted or a file needs to be added to it.
Bug Upstream

Most helpful comment

@moorereason done! And I found a couple things along the way required to create the error:

  1. Must be using a theme (and have it set in the config)
  2. Must have an empty folder in /static and it _must have_ a matching empty folder in the theme's ./static directory! (This feels like the important bit.)

image 2019-02-22 at 11 42 11 am

If I renamed the /static/css folder to /static/empty-test the error went away. But if I added a matching folder /themes/empty-dir-theme/static/empty-test the error came back.

Repo here: https://github.com/themartorana/hugo-empty-dir-test-site

All 9 comments

Interesting. I can't reproduce it neither on 0.54 nor on HEAD commit of the repo. Can you create a repo with the site that's failing to build?

Nothing significant has changed in my environment in the past few days, but I now seem to be unable to replicate this, even though I could make this trigger over and over and over just a few days ago. I'll re-open if I see it again and can provide any more information on what particular circumstances make it happen.

Appears (to me) to be an empty folder _inside of_ static.

Hugo:
Hugo Static Site Generator v0.54.0/extended darwin/amd64 BuildDate: unknown

My layout:

...
▶ resources
▼ static
    ▼ css
        site.css
    ▼ js
▶ themes
...

As soon as I add a file to static/js Hugo renders fine. Without any files, Hugo errors:

❯ hugo
Total in 2 ms
Error: Error copying static files: EOF

Cheers.

This looks like a bug to me. Readdir in Golang returns io.EOF when a directory is empty, which I suspect is what happens here -- and it shouldn't fail.

It's strange, on my machine everything works fine. Here is the output of hugo version:
Hugo Static Site Generator v0.54.0/extended darwin/amd64 BuildDate: unknown
I'm using https://github.com/bep/hugotest as a test hugo site. It builds without any issues, no matter if I add an empty folder or not to static.

@themartorana, can you provide a test site that reproduces this issue?

@moorereason done! And I found a couple things along the way required to create the error:

  1. Must be using a theme (and have it set in the config)
  2. Must have an empty folder in /static and it _must have_ a matching empty folder in the theme's ./static directory! (This feels like the important bit.)

image 2019-02-22 at 11 42 11 am

If I renamed the /static/css folder to /static/empty-test the error went away. But if I added a matching folder /themes/empty-dir-theme/static/empty-test the error came back.

Repo here: https://github.com/themartorana/hugo-empty-dir-test-site

@themartorana, excellent! 🏆

I'm able to reproduce the issue with your repo after the following:

sh$ mkdir content static themes/empty-dir-theme/static && hugo
Total in 1 ms
Error: Error copying static files: EOF

sh$ hugo env
Hugo Static Site Generator v0.55.0-DEV-908692FA linux/amd64 BuildDate: 2019-02-22T09:49:09-0600
GOOS="linux"
GOARCH="amd64"
GOVERSION="go1.11.5"
Was this page helpful?
0 / 5 - 0 ratings

Related issues

digitalcraftsman picture digitalcraftsman  ·  3Comments

kaushalmodi picture kaushalmodi  ·  3Comments

vielmetti picture vielmetti  ·  3Comments

sigma picture sigma  ·  3Comments

nikolas picture nikolas  ·  3Comments