gohugoio/hugo · warning
found _vendor dir without modules.txt, skip delete
Error message
found _vendor dir without modules.txt, skip delete
What it means
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.
Source
Thrown at modules/client.go:762
// Nothing changed
return nil, nil
}
return b.Bytes(), nil
}
func (c *Client) rmVendorDir(vendorDir string) error {
modulestxt := filepath.Join(vendorDir, vendorModulesFilename)
if _, err := c.fs.Stat(vendorDir); err != nil {
return nil
}
_, err := c.fs.Stat(modulestxt)
if err != nil {
// If we have a _vendor dir without modules.txt it sounds like
// a _vendor dir created by others.
return errors.New("found _vendor dir without modules.txt, skip delete")
}
return c.fs.RemoveAll(vendorDir)
}
func (c *Client) runGo(
ctx context.Context,
stdout io.Writer,
args ...string,
) error {
if c.goBinaryStatus != 0 {
return nil
}
stderr := new(bytes.Buffer)
argsv := collections.StringSliceToInterfaceSlice(args)
argsv = append(argsv, hexec.WithEnviron(c.environ))View on GitHub ↗ (pinned to 8a468df065)
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.
Example fix
# before hugo mod vendor # refuses: _vendor without modules.txt # after rm -rf _vendor # after confirming contents are regenerable hugo mod vendor
Defensive patterns
Strategy: validation
Validate before calling
// this is a log warning, not a returned error: Hugo refuses to delete a _vendor dir it didn't create
info, err := os.Stat(filepath.Join(workingDir, "_vendor", "modules.txt"))
if err != nil {
// _vendor exists but wasn't produced by 'hugo mod vendor' — remove or regenerate it manually
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- %q is a root folder and not allowed as cache dir
- failed to save file %q:: %w
- failed to resolve output path %q: %w
- failed to copy %q to %q: %w
- target path "%s" exists but is not a directory
AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31).
Data as JSON: /data/errors/3fd7ba4cbbe3392f.json.
Report an issue: GitHub ↗.