{"record":{"id":"fedd72298e7d115d","repo":"gohugoio/hugo","slug":"failed-to-create-workingdir-w","errorCode":null,"errorMessage":"failed to create workingDir: %w","messagePattern":"failed to create workingDir: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/commandeer.go","lineNumber":261,"sourceCode":"\t}\n\tr.resolveEnvironment(false)\n\tcc, _, err := r.commonConfigs.GetOrCreate(key, func(key configKey) (*commonConfig, error) {\n\t\tvar dir string\n\t\tif r.source != \"\" {\n\t\t\tdir, _ = filepath.Abs(r.source)\n\t\t} else {\n\t\t\tdir, _ = os.Getwd()\n\t\t}\n\n\t\tif cfg == nil {\n\t\t\tcfg = config.New()\n\t\t}\n\n\t\tif !cfg.IsSet(\"workingDir\") {\n\t\t\tcfg.Set(\"workingDir\", dir)\n\t\t} else {\n\t\t\tif err := os.MkdirAll(cfg.GetString(\"workingDir\"), 0o777); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to create workingDir: %w\", err)\n\t\t\t}\n\t\t}\n\n\t\t// Load the config first to allow publishDir to be configured in config file.\n\t\tconfigs, err := allconfig.LoadConfig(\n\t\t\tallconfig.ConfigSourceDescriptor{\n\t\t\t\tFlags:                    cfg,\n\t\t\t\tFs:                       hugofs.Os,\n\t\t\t\tFilename:                 r.cfgFile,\n\t\t\t\tConfigDir:                r.cfgDir,\n\t\t\t\tEnvironment:              r.environment,\n\t\t\t\tLogger:                   r.logger,\n\t\t\t\tIgnoreModuleDoesNotExist: key.ignoreModulesDoesNotExists,\n\t\t\t\tSkipNpmCheck:             key.skipNpmCheck,\n\t\t\t},\n\t\t)\n\t\tif err != nil {\n\t\t\treturn nil, err","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/commands/commandeer.go#L243-L279","documentation":"In ConfigFromProvider (commandeer.go:257-262), when workingDir is explicitly set in config, Hugo calls os.MkdirAll to ensure it exists. If the directory cannot be created (permissions, invalid path), the build aborts with this wrapped error. When workingDir is not set, it defaults to the current directory and this path is skipped.","triggerScenarios":"Setting workingDir (via config or flags) to an unwritable parent, an invalid path, or a path on a read-only filesystem.","commonSituations":"CI/CD environments with restricted write access; misconfigured workingDir; container with read-only mounts.","solutions":["Verify the workingDir path is valid and its parent is writable","Use a workingDir the current user can create and write to","Run Hugo with appropriate filesystem permissions"],"exampleFix":"# before\nworkingDir = \"/opt/readonly/myproject\"\n# after\nworkingDir = \"/home/user/projects/myproject\"","handlingStrategy":"validation","validationCode":"// Verify workingDir is creatable before launching Hugo.\nfunc ensureWorkingDir(dir string) error {\n    parent := filepath.Dir(dir)\n    if info, err := os.Stat(parent); err != nil || !info.IsDir() {\n        return fmt.Errorf(\"parent of workingDir %q is not accessible\", dir)\n    }\n    return os.MkdirAll(dir, 0o755)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set workingDir to a path under the current user's home or a known-writable location","In CI, ensure the workspace directory is created and writable before running Hugo","Avoid pointing workingDir at system directories"],"tags":["config","workingdir","filesystem","permissions","cli","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}