Skip to content
Latchkey

Earthly "RUN --push only allowed" / --push not enabled in CI

Earthly separates building from pushing. RUN --push and SAVE IMAGE --push execute only when you pass --push on the earthly command line. Without it, push steps are skipped or rejected, so nothing reaches the registry.

What this error means

A push step is skipped, or Earthly reports a push-only command is not allowed, because the build was invoked without the top-level --push flag.

earthly
+deploy | RUN --push ./publish.sh
Error: RUN --push is only allowed when the build is invoked with earthly --push

Common causes

The build ran without --push

Push-only commands are gated behind the top-level --push flag so builds are side-effect free by default. Without it, they do not run.

Push logic placed outside a --push guarded step

A registry push runs in a normal RUN rather than a RUN --push, so it either always runs or never runs as intended.

How to fix it

Invoke earthly with --push

Pass --push at the command line so RUN --push and SAVE IMAGE --push execute.

Terminal
earthly --push +deploy

Gate side effects behind --push

Mark registry and deploy commands with --push so they only run in the pushing invocation.

Earthfile
deploy:
    BUILD +image
    RUN --push ./publish.sh

How to prevent it

  • Use --push only on branches that should publish.
  • Keep side effects inside RUN --push / SAVE IMAGE --push.
  • Run PR builds without --push so they never publish.

Related guides

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