{"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":"exception","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/8a468df065a75c1c7cf9f6850f32148746590ea5/modules/client.go#L211-L247","documentation":"Raised by `hugo mod vendor` (modules/client.go:229) when a module selected for vendoring reports no mounts. Vendoring copies each mount's files into _vendor/, so a module with a nil mount set would produce an empty, broken vendor entry; Hugo fails fast instead (see issue 8239).","triggerScenarios":"Running hugo mod vendor when a collected module (t.Owner() != nil, is a Go module or has vendor enabled, not excluded by noVendor) has Mounts() == nil — typically a module whose config couldn't produce any mounts, e.g. an empty module or one whose declared dirs don't exist.","commonSituations":"Vendoring a freshly created or empty module repo with no content/layouts/etc. directories and no explicit mounts; importing a Go module that isn't actually a Hugo module; a module whose hugo config disables all default mounts.","solutions":["Give the module at least one mountable directory (content, layouts, assets, static, ...) or an explicit [[module.mounts]] entry in its config.","If the import shouldn't be vendored at all, add it to module.noVendor in the project config.","Remove the import if it's not a real Hugo module.","Run hugo mod graph to confirm which module the reported path/version refers to."],"exampleFix":"# in the offending module's hugo.toml\n[[module.mounts]]\nsource = \"layouts\"\ntarget = \"layouts\"","handlingStrategy":"validation","validationCode":"// Ensure every module to be vendored has at least one mount\nfor _, m := range client.Graph() {\n    if len(m.Mounts()) == 0 {\n        return fmt.Errorf(\"module %s has no mounts; add [module.mounts] or remove the import before vendoring\", m.Path())\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := client.Vendor(); err != nil {\n    if strings.Contains(err.Error(), \"need at least one mount\") {\n        return fmt.Errorf(\"a module imports nothing usable — add mounts or drop the import: %w\", err)\n    }\n    return err\n}","preventionTips":["Only import modules that actually provide Hugo components; drop pure-Go dependencies from [module.imports]","Run `hugo mod graph` before `hugo mod vendor` to confirm each module contributes mounts","Add explicit mounts in the import config when a module lacks its own hugo config"],"tags":["hugo","modules","vendoring","hugo-mod"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}