{"record":{"id":"a0c4c559247e906b","repo":"gohugoio/hugo","slug":"failed-to-apply-mounts-for-project-w","errorCode":null,"errorMessage":"failed to apply mounts for project: %w","messagePattern":"failed to apply mounts for project: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/collect.go","lineNumber":370,"sourceCode":"\n\tif !moduleImport.IgnoreConfig {\n\t\tif err := c.applyThemeConfig(ma); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tif err := c.applyMounts(moduleImport, ma); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn ma, nil\n}\n\nfunc (c *collector) addAndRecurse(owner *moduleAdapter) error {\n\tmoduleConfig := owner.Config()\n\tif owner.projectMod {\n\t\tif err := c.applyMounts(Import{}, owner); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to apply mounts for project: %w\", err)\n\t\t}\n\t}\n\tseen := make(map[pathVersionKey]bool)\n\tfor _, moduleImport := range moduleConfig.Imports {\n\t\tif moduleImport.Disable {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Prevent cyclic references.\n\t\tif v := c.isPathSeen(moduleImport.Path, owner); v != nil && v != owner {\n\t\t\tcontinue\n\t\t}\n\n\t\ttc, err := c.getAndCreateModule(owner, moduleImport)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/modules/collect.go#L352-L388","documentation":"In addAndRecurse, the project module itself (owner.projectMod true) has its mounts applied first; if applyMounts errors, the failure is wrapped with this project-specific context. It pinpoints the problem to the project's own mount configuration rather than a dependency's.","triggerScenarios":"The top-level hugo.toml/hugo.yaml defines a [[mounts]] block (or the project's module config has mounts) that fails normalisation — bad source path, missing source dir that isn't auto-created, or a mount whose source can't be resolved relative to the project.","commonSituations":"A [[module.mounts]] source pointing at a folder that doesn't exist (and isn't the publish dir or hugo_stats.json which Hugo auto-creates), an absolute source path with permission issues, or a recently-reorganised project where mount sources were not updated.","solutions":["Inspect the project's [[module.mounts]] entries and verify each `source` exists relative to the project root.","Create any missing mount source directories, or correct the source path.","If you reorganised folders, update every mount source/target to match the new layout.","Run `hugo config` to dump the resolved mounts and spot the bad entry."],"exampleFix":"// before (hugo.toml): source renamed\n[[module.mounts]]\nsource = \"content\"\ntarget = \"content\"\n[[module.mounts]]\nsource = \"old-assets\"\ntarget = \"assets\"\n// after: fix the stale source\n[[module.mounts]]\nsource = \"assets\"\ntarget = \"assets\"","handlingStrategy":"validation","validationCode":"// Validate every project mount source exists before build\nfunc validateProjectMounts(projectDir string, mounts []Mount) error {\n  for _, m := range mounts {\n    src := m.Source\n    if !filepath.IsAbs(src) { src = filepath.Join(projectDir, src) }\n    if _, err := os.Stat(src); err != nil {\n      return fmt.Errorf(\"mount source missing: %s\", src)\n    }\n  }\n  return nil\n}","typeGuard":"null","tryCatchPattern":"// On 'failed to apply mounts for project:', read the wrapped error to find the offending mount.","preventionTips":["After reorganising a project, audit [[module.mounts]] entries.","Create mount source dirs in your setup script.","Use `hugo config` to dump resolved mounts in CI."],"tags":["modules","config","mounts","hugo-module"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}