Runtime error (invalid memory address or nil pointer dereference) while running the server

My version of Hugo was more than a year old. I just updated it, and since then, I get the following error when I make any changes to any file, while Hugo server is running:

Change detected, rebuilding site.
2019-08-11 18:31:15.991 +0200
Source changed "E:\\P2W\\content\\en\\themes\\": WRITE
Total in 0 ms
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x18 pc=0xb635f9]

goroutine 309 [running]:*fileInfoMeta).IsDir(0xc001007600, 0xc000349800)
        <autogenerated>:1 +0x39*FilterFs).LstatIfPossible(0xc000349820, 0xc00478e26a, 0x7, 0x8, 0x0, 0xc0000a4960, 0x1, 0x3000d)
        /root/project/hugo/hugofs/filter_fs.go:152 +0x9c*FilterFs).Stat(0xc000349820, 0xc00478e26a, 0x7, 0x203000d, 0x203000d, 0x3000d, 0x20)
        /root/project/hugo/hugofs/filter_fs.go:208 +0x46*pagesCollector).collectDir(0xc000e26e10, 0xc00478e26a, 0x7, 0xc0038c8e01, 0xc001390030, 0xc00478e240, 0x40)
        /root/project/hugo/hugolib/pages_capture.go:156 +0x6d*pagesCollector).Collect(0xc000e26e10, 0x0, 0x0)
        /root/project/hugo/hugolib/pages_capture.go:134 +0x3fa*Site).readAndProcessContent(0xc000456a80, 0xc000fa5900, 0x1, 0x1, 0x1, 0x1)
        /root/project/hugo/hugolib/site.go:1317 +0x190*Site).processPartial(0xc000456a80, 0xc0010071c0, 0x2, 0x2, 0x30, 0x30, 0x15452e0, 0xc0034b8d80)
        /root/project/hugo/hugolib/site.go:1064 +0xced*HugoSites).process(0xc000133a00, 0xc0007ac8c0, 0xc00438d7a0, 0x2, 0x2, 0xc0038c9800, 0x20)
        /root/project/hugo/hugolib/hugo_sites_build.go:218 +0xb4*HugoSites).Build.func2.1()
        /root/project/hugo/hugolib/hugo_sites_build.go:96 +0x5e
runtime/trace.WithRegion(0x1a2c620, 0xc00438d830, 0x1673484, 0x7, 0xc0038c98d8)
        /usr/local/go/src/runtime/trace/annotation.go:137 +0xf0*HugoSites).Build.func2(0xc0038c9958, 0x20)
        /root/project/hugo/hugolib/hugo_sites_build.go:98 +0x1b7*HugoSites).Build.func3()
        /root/project/hugo/hugolib/hugo_sites_build.go:115 +0x36
runtime/trace.WithRegion(0x1a2c620, 0xc00438d830, 0x1673422, 0x7, 0xc0038c9a68)
        /usr/local/go/src/runtime/trace/annotation.go:137 +0xf0*HugoSites).Build(0xc000133a00, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc00438d800, 0xc00438d7a0, 0x2, ...)
        /root/project/hugo/hugolib/hugo_sites_build.go:117 +0x7e0*commandeer).rebuildSites(0xc000083040, 0xc00438d7a0, 0x2, 0x2, 0x0, 0x0)
        /root/project/hugo/commands/hugo.go:738 +0x320*commandeer).handleEvents(0xc000083040, 0xc002b88ba0, 0xc0013d8e60, 0xc002d4ec90, 0x2, 0x2, 0xc00438d0e0)
        /root/project/hugo/commands/hugo.go:1095 +0x6fe*commandeer).newWatcher.func1(0xc002b88ba0, 0xc000083040, 0xc0013d8e60, 0xc00438d0e0)
        /root/project/hugo/commands/hugo.go:842 +0x1df
created by*commandeer).newWatcher
        /root/project/hugo/commands/hugo.go:838 +0x295

I’ve removed almost every piece of code, hoping to find the cause, but it didn’t work. Now my pages are empty, and still, any change to any file causes that runtime error. However, I can still build the website. I even brought back the code and built the website, and the pages seem to be fine.

Any ideas?

I just checked it on a different website that I have, and it worked fine. So, it has something to do with the code on this website… probably… but how can I find it?!

I’ve found the cause of the problem! I have content folders named “themes” (e.g., /en/themes/) and I don’t get a runtime error if I change their name to something else. Seems like there’s a conflict between them and the /themes/ folder in the root.

It’s not supposed to be like this, is it?

EDIT: actually, I just renamed it, and also renamed the only other “themes” folder which was /fr/themes/ to /fr/theme/ (the name is different in all other languages I have), and again, I got an error. Then I moved the French version back to “themes” and now it’s fine!

I’ve tried many combinations, and I realized something else: similar folders in different languages should either have the same name in all languages, or no two of them share the same name! For example, it’s fine to have a folder called “processes” in all languages, but I get an error if one of them is called “processen” or something else. On the other hand, if the names are all different (e.g., processes, processe, procesos, processus, processi, etc.), it’s happy again.

By the way, I use translationkeys to link files.