{"record":{"id":"fdbc67fb73d7e5aa","repo":"gohugoio/hugo","slug":"failed-to-open-dir-q-q","errorCode":null,"errorMessage":"failed to open dir %q: %q","messagePattern":"failed to open dir %q: %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/collect.go","lineNumber":674,"sourceCode":"}\n\n// Matches postcss.config.js etc.\nvar commonJSConfigs = regexp.MustCompile(`^(babel|postcss|tailwind)\\.config\\.(c|m)?js$`)\n\nfunc (c *collector) mountCommonJSConfig(owner *moduleAdapter, mounts []Mount) ([]Mount, error) {\n\tfor _, m := range mounts {\n\t\tif strings.HasPrefix(m.Target, files.JsConfigFolderMountPrefix) {\n\t\t\t// This follows the convention of the other component types (assets, content, etc.),\n\t\t\t// if one or more is specified by the user, we skip the defaults.\n\t\t\t// These mounts were added to Hugo in 0.75.\n\t\t\treturn mounts, nil\n\t\t}\n\t}\n\n\t// Mount the common JS config files.\n\td, err := c.fs.Open(owner.Dir())\n\tif err != nil {\n\t\treturn mounts, fmt.Errorf(\"failed to open dir %q: %q\", owner.Dir(), err)\n\t}\n\tdefer d.Close()\n\tfis, err := d.(fs.ReadDirFile).ReadDir(-1)\n\tif err != nil {\n\t\treturn mounts, fmt.Errorf(\"failed to read dir %q: %q\", owner.Dir(), err)\n\t}\n\n\thasPackageHugoJSON := false\n\tfor _, fi := range fis {\n\t\tif fi.Name() == files.FilenamePackageHugoJSON {\n\t\t\thasPackageHugoJSON = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfor _, fi := range fis {\n\t\tn := fi.Name()\n","sourceCodeStart":656,"sourceCodeEnd":692,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/modules/collect.go#L656-L692","documentation":"mountCommonJSConfig opens owner.Dir() with c.fs.Open to scan for JS config files (babel/postcss/tailwind.config.js, package.hugo.json); if the open fails for a reason other than not-exist (which is tolerated elsewhere), the raw error is surfaced. Indicates a filesystem/permission problem on an already-resolved module directory.","triggerScenarios":"A module whose Dir() exists in metadata but cannot be opened — permission denied, symlink loop, removed between resolution and scan, or an afero filesystem layer rejecting the open.","commonSituations":"Permission drift on the module cache/theme dir, a broken symlink in a theme, network filesystem hiccup, or a container mount that omits the dir.","solutions":["Check permissions on the dir named in the error: `ls -ld <dir>` and chmod/chown as needed.","Resolve broken symlinks inside the module/theme dir.","For cache dirs, `go clean -modcache` then rebuild to restore a clean tree.","In containers, confirm the volume mount actually includes the module dir."],"exampleFix":"// before: theme dir not readable\nchmod -R go-rx themes/mytheme\n// after: restore read+execute on the dir\nchmod -R a+rX themes/mytheme","handlingStrategy":"validation","validationCode":"// Ensure module/theme dirs are openable before build\nfunc ensureDirOpenable(dir string) error {\n  f, err := os.Open(dir)\n  if err != nil { return fmt.Errorf(\"cannot open %s: %w\", dir, err) }\n  return f.Close()\n}","typeGuard":"null","tryCatchPattern":"// if errors.Is(err, fs.ErrPermission) { chmod + retry }","preventionTips":["Set read+execute perms on theme/module dirs in setup.","Avoid broken symlinks in theme trees.","In containers, mount module/theme dirs readably."],"tags":["modules","filesystem","permissions","hugo-module"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}