Tobias Watzl

Programmer, photographer, engineer.

When writing a blog post turns into a bug hunt.

How writing a new blog post turned into a multi hour bug hunt over several layers.

Tobias Watzl

4-Minute Read

Today I finally managed to finish another blog post. It was about 2pm when I started my Hugo again to test it.

Recently someone told me that my frontpage was broken and no blog posts are displayed. Odd I thought, but I did not really have the time to fix it. Today when I wanted to publish a new blog post I though why not direclty fix that issue as well. After all it can’t be that hard to fix or can it?

A broken frontpage is not nice.

A broken frontpage is not nice.

Well if you are a programmer then for sure you are familiar with the concept of Yak-Shaving and this was no different.

Step 1: find the cause

At first I thought that I had misconfigured something in my config.toml when I last worked on my privacy extension for Hugo. I was looking through all kinds of commits on my blog, diffed files and so on, but I could find nothing that fixed it. After some time I found something about index.html and _index.html, however I could not get it to work on my version.

Finally I found the culprit. For working on my privacy plugin I needed a newer Hugo version. One that supports Hugo modules. So I updated the version I use for generating my blog from 0.55 to 0.63. And then finally I found the following GitHub issue: https://github.com/gohugoio/hugo/issues/6238.

That means the way Hugo generates the index page has changed. And it shows no warning that I was missing the necessary configuration files. So I thought fixing that is easy, just update the theme, write a Markdown file for the index page and done. And by the way I could directly update Hugo again to the latest version.

Step 2: another mistake

It turns out that was a big mistake. The latest version of Hugo does not process the SCSS files from the theme. This issue was described in Hugo’s FAQ and it turns out I needed to just download another release .tar.gz and run it.

Well, no. Soon I was greeted by the following error:

$ docker run --rm -it -v $PWD:/src -p 1313:1313 -u hugo hugo-builder:0.69.0 hugo server -w --bind=0.0.0.0
standard_init_linux.go:211: exec user process caused "no such file or directory"

As you can see this error is not very descriptive. Several issues on GitHub suggested errors in the dockerfile. However it should turn out that was not the case.

I ran /bin/sh within the container found the hugo executable and tried to run it. But I simply got a “file not found” error. Despite ls showing that the file was present. What the heck was going on?

After some guided analysis it turned out I was missing the libstdc++ and libgcc packages for alpine. But: Still no luck! It just did not want to run the executable. Some sources suggested that the binary was for the wrong architecture, but this was not the case. It was indeed for 64-bit systems.

After some more search I finally found the culprit and the fix for it.

Finally Hugo would run again:

$ docker run --rm -it -v $PWD:/src -p 1313:1313 hugo-builder:0.69.0 /bin/sh
/src # ./hugo
Total in 1 ms
Error: Unable to locate config file or config directory. Perhaps you need to create a new site.
       Run `hugo help new` for details.

/src # exit

Now back to my blog 😁

Step 3: finale

After all those updates what was left for me to do was to clean up some drafts which now would have shown on the front page and to fine tune some things.

I had to add the new configuration option mainSections = ["blog", "post"] to my config.toml and maybe I will do some more fine tuning to the theme, but not today.

Despite how long everything took I think it still paid off. After all maintenance has to be done from time to time.

It’s 5pm now. Time for lunch! :D

Recent posts

Categories

About

Blog