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

  1. Inspect `_vendor`; if its contents are disposable, delete it manually and re-run `hugo mod vendor`.
  2. If it contains custom content, move that content elsewhere (e.g. a module mount) before vendoring.
  3. 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

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


AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31). Data as JSON: /data/errors/3fd7ba4cbbe3392f.json. Report an issue: GitHub ↗.