hugo: PostCSS on Windows does not work in directories with spaces

I’m still having this issue as of 5/28/2020. I’ve narrowed down the issue to here: https://github.com/gohugoio/hugo/blob/6add6d77b48cf0aab8b39d7a2bddedb1aa2a52b8/resources/resource_transformers/postcss/postcss.go#L192

Specifically, Go’s exec.Command will treat spaces in parameters as different parameters, so they must be escaped or quoted if they have spaces.

I do not have the capabilities (right now) to get Hugo building on my machine, but I believe the simplest fix will be somehow escaping the string when passing it to exec.Command.

I believe, but cannot be certain, that this line should fix this issue:

configFile = `"` + configFile + `"`

This was closed as stale in #6283, but I think my solution should fix the problem.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

This came up again yesterday: https://discourse.gohugo.io/t/failed-to-transform-path-not-found/37309

On Windows, reproduce with:

git clone --single-branch -b hugo-github-issue-7333 https://github.com/jmooring/hugo-testing "hugo github issue 7333"
cd "hugo github issue 7333"
npm install
hugo server

There’s a workaround where you don’t have to change the project path:

  1. Delete the postcss.config.js file from the root of the project directory.
  2. Add the following (or similar) to package.json
  "postcss": {
    "plugins": {
      "autoprefixer": {}
    }
  }

So here’s a repro.

With https://github.com/jannepeltola/hugo_issue_7333/, here’s what happens:

C:\Users\Janne Peltola\Documents\GitHub\hugo_issue_7333>hugo env
Hugo Static Site Generator v0.80.0/extended windows/amd64 BuildDate: unknown
GOOS="windows"
GOARCH="amd64"
GOVERSION="go1.15.1"

C:\Users\Janne Peltola\Documents\GitHub\hugo_issue_7333>hugo server
Start building sites …
WARN 2021/01/14 15:54:56 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 2021/01/14 15:54:56 found no layout file for "HTML" for kind "taxonomy": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
Built in 24 ms
Error: Error building site: POSTCSS: failed to transform "css/main.css" (text/css): 'C:\Users\Janne' is not recognized as an internal or external command,
operable program or batch file.