Skip to content
Latchkey

GoReleaser "dist is not empty, use --clean" in CI

GoReleaser writes artifacts to dist/ and refuses to run if that folder already has content, to avoid mixing old and new builds. The --clean flag removes it first; the old --rm-dist flag was removed.

What this error means

GoReleaser fails with "dist is not empty, use the --clean flag to remove it" or, on newer versions, "unknown flag: --rm-dist".

Terminal
⨯ release failed after 0s
  error=dist is not empty, please remove before running or use the --clean flag

Common causes

A leftover dist directory

A cached workspace or a previous step left dist/ populated, and GoReleaser will not overwrite it silently.

The removed --rm-dist flag

Older workflows call --rm-dist, which no longer exists; the current flag is --clean.

How to fix it

Use --clean

Pass --clean so GoReleaser removes dist/ before building.

.github/workflows/release.yml
- uses: goreleaser/goreleaser-action@v6
  with:
    args: release --clean

Replace --rm-dist with --clean

Update any old invocation; --rm-dist was renamed to --clean.

Terminal
goreleaser release --clean

How to prevent it

  • Always pass --clean in CI so dist/ starts fresh.
  • Gitignore dist/ so it never gets committed or cached dirty.
  • Search workflows for the removed --rm-dist flag and update them.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →