#1129·mockery

`--dir` flag not recognized in v3 despite documentation

Author: niklodCreated Nov 21, 2025Updated Nov 24, 2025

Description

Problem

I'm attempting to migrate from mockery v2 to v3. In v2, I successfully used the --dir flag to generate mocks for specific directories:

bash
mockery --dir internal/path/ \
  --inpackage \
  --all

After upgrading to v3, this command now fails with:

Error: unknown flag: --dir

Expected Behavior

According to the v3 configuration documentation, the parameter table lists dir as a configuration option with a default value of "{{.InterfaceDir}}". The documentation states:

"Config can not only be specified from the .yml file, but also from CLI parameters (where available) and environment variables."

This suggests that dir should be available as a CLI flag, similar to how other parameters like --all, --inpackage, etc., work.

Current Workaround

I'm aware that I can use a .mockery.yml config file with the packages section to specify directories:

yaml
packages:
  internal/path/:
    config:
      all: true
      inpackage: true

However, this significantly changes the workflow, especially for projects with many directories that need mock generation (I have 99+ usages of mockery --dir across my makefiles).

Questions

  1. Is the --dir flag intentionally removed in v3, or is this a bug?
  2. If intentionally removed, should the documentation be updated to clarify which parameters are available as CLI flags?
  3. Is there a recommended migration path for projects heavily relying on the --dir flag beyond converting everything to YAML config?

Environment

  • mockery version: v3.x (please specify your exact version)
  • Operating System: macOS (darwin 24.6.0)
  • Go version: go1.25.2 darwin/arm64

Additional Context

The migration from v2 to v3 would be much smoother if either:

  • The --dir flag is restored/fixed in v3, or
  • Clear migration documentation is provided explaining the new approach and why --dir is no longer supported