{"record":{"id":"e64c4f3929e7cab8","repo":"gohugoio/hugo","slug":"q-not-found","errorCode":null,"errorMessage":"%q not found","messagePattern":"%q not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/collect.go","lineNumber":331,"sourceCode":"\t\t\t// Fall back to project/themes/<mymodule>\n\t\t\tif moduleDir == \"\" {\n\t\t\t\tvar err error\n\t\t\t\tmoduleDir, err = c.createThemeDirname(modulePath, owner.projectMod || moduleImport.pathProjectReplaced)\n\t\t\t\tif err != nil {\n\t\t\t\t\tc.err = err\n\t\t\t\t\treturn nil, nil\n\t\t\t\t}\n\t\t\t\tif found, _ := afero.Exists(c.fs, moduleDir); !found {\n\t\t\t\t\t//lint:ignore ST1005 end user message.\n\t\t\t\t\tc.err = c.wrapModuleNotFound(fmt.Errorf(`module %q not found in %q; either add it as a Hugo Module or store it in %q.`, modulePath, moduleDir, c.ccfg.ThemesDir))\n\t\t\t\t\treturn nil, nil\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif found, _ := afero.Exists(c.fs, moduleDir); !found {\n\t\tc.err = c.wrapModuleNotFound(fmt.Errorf(\"%q not found\", moduleDir))\n\t\treturn nil, nil\n\t}\n\n\tif !strings.HasSuffix(moduleDir, fileSeparator) {\n\t\tmoduleDir += fileSeparator\n\t}\n\n\tma := &moduleAdapter{\n\t\tdir:          moduleDir,\n\t\tvendor:       vendored,\n\t\tgomod:        mod,\n\t\tversion:      versionMod,\n\t\tversionQuery: requestedVersionQuery,\n\t\t// This may be the owner of the _vendor dir\n\t\towner: realOwner,\n\t}\n\n\tif mod == nil {","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/modules/collect.go#L313-L349","documentation":"Final existence gate in getAndCreateModule: a moduleDir was computed (via go module, replace, or themesDir resolution) but afero.Exists reports it absent on the filesystem. Distinct from 471 in that the directory path was resolved, just not present — typically a broken replace, a vanished cache, or a race where the dir was removed mid-build.","triggerScenarios":"go list returned a Dir for a module but that directory no longer exists (cache evicted, replace target deleted, vendored dir partially removed), or themesDir path computed but the folder was deleted between resolution and this check.","commonSituations":"Manual deletion of part of the module cache, a replace directive pointing at a moved folder, vendored modules where vendor/<path> is incomplete, or a race with another process cleaning the build dir.","solutions":["For cached Go modules: `go clean -modcache && hugo mod clean` then rebuild to re-download.","For replaced modules, verify the replace target directory exists at the path go list reported.","For vendored builds, regenerate: `hugo mod vendor`.","Ensure nothing (antivirus, CI cleanup, parallel builds) deletes the module dir during the build."],"exampleFix":"// before: replace target vanished\nreplace github.com/x/y => ../y\n// after: ensure target exists or re-vendor\ngit clone https://github.com/x/y ../y\nhugo mod vendor","handlingStrategy":"validation","validationCode":"// Verify resolved module dirs actually exist before relying on them\nimport \"os\"\n\nfunc ensureModuleDirExists(dir string) error {\n  info, err := os.Stat(dir)\n  if err != nil { return fmt.Errorf(\"module dir missing: %s\", dir) }\n  if !info.IsDir() { return fmt.Errorf(\"module path is not a dir: %s\", dir) }\n  return nil\n}","typeGuard":"null","tryCatchPattern":"// if errors.Is(err, fs.ErrNotExist) { re-download or re-vendor }","preventionTips":["Don't hand-delete cache/vendor entries mid-build.","Keep replace targets under version control or reclone in CI.","Regenerate vendor/ after dependency changes.","Guard against parallel cleaners on shared cache dirs."],"tags":["modules","filesystem","hugo-module","caching"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}