{"id":"3fd7ba4cbbe3392f","repo":"gohugoio/hugo","slug":"found-vendor-dir-without-modules-txt-skip-delete","errorCode":null,"errorMessage":"found _vendor dir without modules.txt, skip delete","messagePattern":"found _vendor dir without modules\\.txt, skip delete","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"modules/client.go","lineNumber":762,"sourceCode":"\t\t// Nothing changed\n\t\treturn nil, nil\n\t}\n\n\treturn b.Bytes(), nil\n}\n\nfunc (c *Client) rmVendorDir(vendorDir string) error {\n\tmodulestxt := filepath.Join(vendorDir, vendorModulesFilename)\n\n\tif _, err := c.fs.Stat(vendorDir); err != nil {\n\t\treturn nil\n\t}\n\n\t_, err := c.fs.Stat(modulestxt)\n\tif err != nil {\n\t\t// If we have a _vendor dir without modules.txt it sounds like\n\t\t// a _vendor dir created by others.\n\t\treturn errors.New(\"found _vendor dir without modules.txt, skip delete\")\n\t}\n\n\treturn c.fs.RemoveAll(vendorDir)\n}\n\nfunc (c *Client) runGo(\n\tctx context.Context,\n\tstdout io.Writer,\n\targs ...string,\n) error {\n\tif c.goBinaryStatus != 0 {\n\t\treturn nil\n\t}\n\n\tstderr := new(bytes.Buffer)\n\n\targsv := collections.StringSliceToInterfaceSlice(args)\n\targsv = append(argsv, hexec.WithEnviron(c.environ))","sourceCodeStart":744,"sourceCodeEnd":780,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/modules/client.go#L744-L780","documentation":"Returned by rmVendorDir when Hugo is about to delete/replace the `_vendor` directory (during `hugo mod vendor`) but finds it lacks `modules.txt`. Hugo only auto-deletes vendor dirs it created itself (which always contain modules.txt); a dir without it looks hand-made, so Hugo refuses to delete it to avoid destroying user content.","triggerScenarios":"Running `hugo mod vendor` in a project whose `_vendor` directory exists but has no `modules.txt` file at its root — typically one created manually or by an older/foreign tool.","commonSituations":"Developers manually creating `_vendor` to drop in theme copies, deleting modules.txt while cleaning up, or a partially copied/checked-out `_vendor` directory missing its metadata.","solutions":["Inspect `_vendor`; if its contents are disposable, delete it manually and re-run `hugo mod vendor`.","If it contains custom content, move that content elsewhere (e.g. a module mount) before vendoring.","If modules.txt was accidentally deleted, restore it from version control."],"exampleFix":"# before\nhugo mod vendor   # refuses: _vendor without modules.txt\n# after\nrm -rf _vendor    # after confirming contents are regenerable\nhugo mod vendor","handlingStrategy":"validation","validationCode":"// this is a log warning, not a returned error: Hugo refuses to delete a _vendor dir it didn't create\ninfo, err := os.Stat(filepath.Join(workingDir, \"_vendor\", \"modules.txt\"))\nif err != nil {\n    // _vendor exists but wasn't produced by 'hugo mod vendor' — remove or regenerate it manually\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only create _vendor via 'hugo mod vendor' so modules.txt is always present","Never place hand-managed files inside _vendor; Hugo skips deleting unrecognized vendor dirs as a safety measure","If the warning appears, delete the stale _vendor directory yourself and re-run 'hugo mod vendor'","Add _vendor to .gitignore only if you regenerate it in CI; otherwise commit it whole, including modules.txt"],"tags":["hugo-mod","vendor","filesystem","safety"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}