gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
76.22k stars 7.55k forks source link

Encountering "The system cannot find the path specified" error when using `nul` as taxonomy on Windows. #12640

Open razonyang opened 5 months ago

razonyang commented 5 months ago

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.128.1-0ff542b4b9cc7b5cb425bbab8bdb5aace81d0c03+extended windows/amd64 BuildDate=2024-07-02T06:46:41Z VendorInfo=gohugoio

Does this issue reproduce with the latest release?

Yes

Reproduce Steps

$ hugo new site hugo-test1

$ cd hugo-test1

Create content/foo.md with the following content.

---
title: Foobar
tags:
  - "Nul"
---

And then build site.

$ hugo
Start building sites …
hugo v0.128.1-0ff542b4b9cc7b5cb425bbab8bdb5aace81d0c03+extended windows/amd64 BuildDate=2024-07-02T06:46:41Z VendorInfo=gohugoio

WARN  found no layout file for "html" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN  found no layout file for "html" for kind "taxonomy": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN  found no layout file for "html" for kind "term": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN  found no layout file for "html" for kind "home": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
Total in 7 ms
Error: error building site: render: failed to render pages: mkdir E:\Workspaces\hugo-test1\public\tags\nul: The system cannot find the path specified.

I'm awared that the issue isn't related to Hugo directly (golang/go#24556), is it possible to handle it in Hugo layer? For example, rename the nul folder as other on Windows?

gj52 commented 4 months ago

please check this old docs

https://msdn.microsoft.com/en-gb/library/windows/desktop/aa365247(v=vs.85).aspx

reserved files names from MS-DOS ...

jmooring commented 2 months ago

The underlying problem isn't limited to taxonomy terms. For example, hugo new nul/p1.md throws:

Error: process: readAndProcessContent: walk: Readdir: readdir C:\temp\foo\content\nul: Incorrect function.

And you're left with a directory named "nul" that you cannot delete.

bep commented 2 months ago

So, if I'm reading the link from @gj52 ... all of these are invalid filenames on Windows?

And also any combination of CON, PRN, AUX, NUL, COM0, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, COM, COM, COM, LPT0, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9, LPT, LPT, and LPT.

jmooring commented 2 months ago

Of all of the file names listed above, only "nul" (including case variations) causes a problem.

Command Notes
hugo new nul.md File is created without error. Error thrown when building the site because there's a directory named "nul" in the path.
hugo new nul/p1.md Error thrown when creating file because there's a directory named "nul" in the path.

Although you can delete a file named "nul.whatever", you cannot delete a directory named "nul". I had to use WSL then access /mnt/c/something.

razonyang commented 3 days ago

This package might be helpful.