{"record":{"id":"c7616be4ad8e671b","repo":"gohugoio/hugo","slug":"cannot-vendor-module-q-need-at-least-one-mount","errorCode":null,"errorMessage":"cannot vendor module %q, need at least one mount","messagePattern":"cannot vendor module %q, need at least one mount","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/client.go","lineNumber":229,"sourceCode":"\t\tif t.Owner() == nil {\n\t\t\t// This is the project.\n\t\t\tcontinue\n\t\t}\n\n\t\tif c.shouldNotVendor(t.PathVersionQuery(false)) || c.shouldNotVendor(t.PathVersionQuery(true)) {\n\t\t\tcontinue\n\t\t}\n\n\t\tif !t.IsGoMod() && !t.Vendor() {\n\t\t\t// We currently do not vendor components living in the\n\t\t\t// theme directory, see https://github.com/gohugoio/hugo/issues/5993\n\t\t\tcontinue\n\t\t}\n\n\t\t// See https://github.com/gohugoio/hugo/issues/8239\n\t\t// This is an error situation. We need something to vendor.\n\t\tif t.Mounts() == nil {\n\t\t\treturn fmt.Errorf(\"cannot vendor module %q, need at least one mount\", t.PathVersionQuery(false))\n\t\t}\n\n\t\tfmt.Fprintln(&modulesContent, \"# \"+t.PathVersionQuery(true)+\" \"+t.Version())\n\n\t\tdir := t.Dir()\n\n\t\tfor _, mount := range t.Mounts() {\n\t\t\tsourceFilename := filepath.Join(dir, mount.Source)\n\t\t\ttargetFilename := filepath.Join(vendorDir, t.PathVersionQuery(true), mount.Source)\n\t\t\tfi, err := c.fs.Stat(sourceFilename)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to vendor module: %w\", err)\n\t\t\t}\n\n\t\t\tif fi.IsDir() {\n\t\t\t\tif err := hugio.CopyDir(c.fs, sourceFilename, targetFilename, nil); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to copy module to vendor dir: %w\", err)\n\t\t\t\t}","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/modules/client.go#L211-L247","documentation":"Returned by Client.Vendor when a module to be vendored has t.Mounts() == nil. Vendoring copies each declared mount's source into _vendor, so a module with no mounts gives Hugo nothing to copy; this is treated as an error condition (see issue #8239) rather than silently producing an empty vendor entry.","triggerScenarios":"Running `hugo mod vendor` (Client.Vendor) on a project where a dependency module is a Go module/theme (t.IsGoMod() or t.Vendor() true) and is not excluded by noVendor, but declares no [[module.mounts]] (its Mounts() returns nil).","commonSituations":"A theme/component module whose hugo.toml/go.mod omits the [[mounts]] section; a module that is pure Go (no Hugo assets) being pulled into the Hugo module graph; switching a theme to module form without adding mounts.","solutions":["Add at least one [[module.mounts]] entry in the offending module's config (source/target/language).","Identify the module via the printed PathVersionQuery in the error, then edit that module.","If the module needs no Hugo assets, exclude it from vendoring with noVendor in your top-level [module] config."],"exampleFix":"# before (in theme module config)\n# no [[module.mounts]] declared\n\n# after\n[[module.mounts]]\nsource = \"layouts\"\ntarget = \"layouts\"\n\n[[module.mounts]]\nsource = \"assets\"\ntarget = \"assets\"","handlingStrategy":"validation","validationCode":"// Ensure modules you intend to vendor have at least one mount.\nfunc moduleHasMounts(m Module) bool {\n    return m.Mounts() != nil && len(m.Mounts()) > 0\n}","typeGuard":"func isVendorableModule(m Module) bool {\n    return (m.IsGoMod() || m.Vendor()) && m.Mounts() != nil\n}","tryCatchPattern":"if err := client.Vendor(); err != nil {\n    if strings.Contains(err.Error(), \"need at least one mount\") {\n        // identify module, add mounts to its config, or exclude via noVendor\n    }\n}","preventionTips":["Always declare [[module.mounts]] in any theme/component intended to be vendored.","Use [module] noVendor to skip modules that need no Hugo assets."],"tags":["modules","vendoring","mounts","config"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}