GoogleContainerTools/skaffold · error
exiting dev mode because first build failed: %w
Error message
exiting dev mode because first build failed: %w
What it means
In `skaffold dev`, an error on the very first build is fatal: there are no previous builds to reuse, so dev mode exits instead of waiting for file changes. The underlying build failure is wrapped with %w.
Source
Thrown at pkg/skaffold/runner/dev.go:284
})
devStart := time.Now()
// First build
var err error
bRes, err := r.Build(ctx, out, artifacts)
for ; err != nil && r.runCtx.Opts.KeepRunningOnFailure; bRes, err = r.Build(ctx, out, artifacts) {
log.Entry(ctx).Warnf("Failed to build artifacts: %v, please fix the error and press any key to continue.", err)
errT := term.WaitForKeyPress()
if errT != nil {
return errT
}
}
if err != nil {
event.DevLoopFailedInPhase(r.devIteration, constants.Build, err)
eventV2.TaskFailed(constants.DevLoop, err)
endTrace()
return fmt.Errorf("exiting dev mode because first build failed: %w", err)
}
// First test
if r.runCtx.IsTestPhaseActive() {
err = r.Test(ctx, out, bRes)
for ; err != nil && r.runCtx.Opts.KeepRunningOnFailure; err = r.Test(ctx, out, bRes) {
log.Entry(ctx).Warnf("Failed to run tests :%v, please fix the error and press any key to continue.", err)
errT := term.WaitForKeyPress()
if errT != nil {
return errT
}
}
if err != nil {
event.DevLoopFailedInPhase(r.devIteration, constants.Build, err)
eventV2.TaskFailed(constants.DevLoop, err)
endTrace()
return fmt.Errorf("exiting dev mode because test failed after first build: %w", err)
}
}View on GitHub (pinned to a1189de023)
Solutions
- Read the wrapped inner error for the actual build failure
- Fix the Dockerfile/build script or source compile error
- Run `skaffold build` once standalone to debug the build in isolation
- Verify registry access and base image tags exist
Example fix
// before FROM node:19-typo // after FROM node:19-alpine
Defensive patterns
Strategy: try-catch
Validate before calling
// verify build inputs before dev
dockerfile && require('fs').existsSync(dockerfile) || exit('missing Dockerfile')
// and pre-warm: skaffold build --dry-run Type guard
function canStartDev(artifacts) {
return artifacts.every(a => a.dockerArtifact == null || typeof a.dockerArtifact.dockerfile === 'string')
} Try / catch
err := r.Dev(ctx, out, dryRun)
if err != nil && strings.Contains(err.Error(), "first build failed") {
log.Fatalf("fix build before dev: %v", err) // do not retry blindly
} Prevention
- Run `skaffold build` once before starting dev on new projects
- Validate Dockerfile and base images exist first
- Check registry auth (docker login / gcloud auth configure-docker) before dev
- Use --keep-running-on-failure while iterating on flaky builds
When it happens
Trigger: Dev() runs r.Build for the first iteration; err != nil and the dev loop cannot continue (no KeepRunningOnFailure retry path applies to the initial build), so the task is marked failed and dev exits.
Common situations: Dockerfile syntax error or missing base image; failing compile step; missing build dependencies on first run of `skaffold dev`; registry authentication failure.
Related errors
- exiting dev mode because test failed after first build: %w
- exiting dev mode because first render failed: %w
- watching files for artifact %q: %w
- configuration changed
- didn't sync any files
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/5abbb95f5106bbc8.
Report an issue: GitHub.