{"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/8a468df065a75c1c7cf9f6850f32148746590ea5/modules/collect.go#L313-L349","documentation":"At modules/collect.go:331, after Hugo has resolved an import to a concrete directory (from a replacement, vendor entry, go module cache, or themesDir), it verifies the directory actually exists on disk. If not, it fails with `%q not found`, wrapped with `ErrNotExist` via `wrapModuleNotFound`. This is a final sanity check that the resolved location is real.","triggerScenarios":"Module collection where the resolved `moduleDir` doesn't exist: a `module.replacements` target pointing at a missing local directory, a stale `_vendor/modules.txt` entry whose files were deleted, or a module-cache path removed by `go clean -modcache`.","commonSituations":"Replacement directives with machine-specific absolute paths shared across machines/CI; partially committed `_vendor` directories (modules.txt present, files missing); cleaning the Go module cache while Hugo still references cached dirs.","solutions":["Check the quoted path in the error — create it or fix the `module.replacements` mapping that produced it.","If vendored, re-run `hugo mod vendor` (or delete `_vendor`) to regenerate a consistent vendor tree.","Re-download modules with `hugo mod get` if the Go module cache was cleaned.","Avoid absolute machine-specific replacement paths in shared config; use env-specific config or relative paths."],"exampleFix":"# before\n[module]\nreplacements = \"github.com/org/theme -> /Users/alice/dev/theme\"  # CI has no such dir\n# after (relative to project, exists in repo)\n[module]\nreplacements = \"github.com/org/theme -> ../theme\"","handlingStrategy":"validation","validationCode":"if fi, err := os.Stat(mountSource); err != nil || !fi.IsDir() {\n    return fmt.Errorf(\"mount source %q missing\", mountSource)\n}","typeGuard":null,"tryCatchPattern":"if err := collectMounts(); err != nil {\n    if strings.Contains(err.Error(), \"not found\") {\n        // a mount source dir or module component is absent\n    }\n    return err\n}","preventionTips":["Verify every `[[module.mounts]]` source directory exists before building","Don't reference optional dirs in mounts; create them or remove the mount","Check .gitignore/CI checkout isn't excluding directories the config mounts"],"tags":["hugo-modules","filesystem","vendoring","configuration"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}