{"id":"833da15ceafa596b","repo":"gohugoio/hugo","slug":"failed-to-create-resource-spec-w","errorCode":null,"errorMessage":"failed to create resource spec: %w","messagePattern":"failed to create resource spec: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"deps/deps.go","lineNumber":272,"sourceCode":"\t}\n\n\tif d.SourceSpec == nil {\n\t\td.SourceSpec = source.NewSourceSpec(d.PathSpec, nil, d.Fs.Source)\n\t}\n\n\tvar common *resources.SpecCommon\n\tif d.ResourceSpec != nil {\n\t\tcommon = d.ResourceSpec.SpecCommon\n\t}\n\n\td.Cfg.BaseConfig()\n\n\tfileCaches := d.Cfg.FileCaches().(filecache.Caches)\n\tfileCaches.SetResourceFs(d.BaseFs.ResourcesCache)\n\n\tresourceSpec, err := resources.NewSpec(d.PathSpec, common, d.WasmDispatchers, fileCaches, d.MemCache, d.BuildState, d.Log, d, d.ExecHelper, d.BuildClosers, d.BuildState)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create resource spec: %w\", err)\n\t}\n\td.ResourceSpec = resourceSpec\n\n\treturn nil\n}\n\n// TODO(bep) rework this to get it in line with how we manage templates.\nfunc (d *Deps) Compile(prototype *Deps) error {\n\tvar err error\n\tif prototype == nil {\n\n\t\tif err = d.TranslationProvider.NewResource(d); err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t}\n\n\tif err = d.TranslationProvider.CloneResource(d, prototype); err != nil {","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/deps/deps.go#L254-L290","documentation":"Wrapper error from Deps initialization (deps/deps.go:270-273): while building Hugo's dependency container, resources.NewSpec — which wires up the resource pipeline (file caches, image processing, minification, security/exec config) — failed, and the underlying cause is wrapped with %w. It is fatal to site construction; Hugo cannot build without a resource spec.","triggerScenarios":"Any error path inside resources.NewSpec during deps.Init: invalid imaging configuration (bad quality/resample filter/anchor values), file cache setup failure (unwritable or invalid cacheDir/resourceDir), invalid minify or security config, or a broken build/output related setting passed through PathSpec.","commonSituations":"Misconfigured [imaging] section in hugo.toml (e.g. unknown resampleFilter or anchor); cacheDir pointing to a read-only or nonexistent location (common in CI containers and read-only filesystems); permission errors on resources/_gen; config regressions after upgrading Hugo versions where defaults or validation changed.","solutions":["Read the wrapped cause after the colon — it names the real failure (imaging config, cache path, etc.).","Validate the [imaging], [caches], and [minify] sections of your site config against the current Hugo docs.","Ensure cacheDir and the resources/_gen directory exist and are writable in the build environment (set HUGO_CACHEDIR to a writable path in CI).","If the error appeared after a Hugo upgrade, diff your config against the release notes for renamed/removed options."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify workingDir and publishDir exist and config is complete before constructing deps\nif cfg.BaseConfig.WorkingDir == \"\" {\n    return errors.New(\"working dir not set\")\n}\nif _, err := os.Stat(cfg.BaseConfig.WorkingDir); err != nil {\n    return fmt.Errorf(\"invalid working dir: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"d, err := deps.New(cfg)\nif err != nil {\n    // wrapped: \"failed to create resource spec: <cause>\" — unwrap for root cause\n    return fmt.Errorf(\"init hugo deps: %w\", err)\n}","preventionTips":["Validate filesystem paths (workingDir, publishDir, cacheDir) and permissions before building deps","Inspect the wrapped cause with errors.Unwrap/errors.Is rather than string-matching the prefix","Ensure image/media config and output formats are valid before calling deps.New","Fail fast at startup: build deps once early and surface the full error chain to the user"],"tags":["hugo","configuration","resources","initialization"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}