GoogleContainerTools/skaffold · error
exiting dev mode because test failed after first build: %w
Error message
exiting dev mode because test failed after first build: %w
What it means
In `skaffold dev`, if the first-iteration test phase fails (and KeepRunningOnFailure is not enabled, or the retry loop exits), dev mode terminates since tests after the first build are treated as blocking. The test error is wrapped with %w.
Source
Thrown at pkg/skaffold/runner/dev.go:300
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)
}
}
defer r.deployer.GetLogger().Stop()
defer r.deployer.GetDebugger().Stop()
// Logs should be retrieved up to just before the deploy
r.deployer.GetLogger().SetSince(time.Now())
// First render
manifests, err := r.Render(ctx, out, r.Builds, false)
for ; err != nil && r.runCtx.Opts.KeepRunningOnFailure; manifests, err = r.Render(ctx, out, r.Builds, false) {
log.Entry(ctx).Warnf("Failed to render :%v, please fix the error and press any key to continue.", err)
errT := term.WaitForKeyPress()
if errT != nil {
return errT
}
}View on GitHub (pinned to a1189de023)
Solutions
- Fix the failing test reported by the wrapped error
- Re-run with --keep-running-on-failure to stay in dev mode while iterating on tests
- Skip tests temporarily with --skip-tests while debugging
- Run the test command manually to reproduce
Example fix
// before skaffold dev // after — stay in dev loop on test failure skaffold dev --keep-running-on-failure
Defensive patterns
Strategy: try-catch
Validate before calling
// run tests once outside dev to pre-validate
if (runCmd('skaffold test').code !== 0) exit('tests fail before dev start') Type guard
function testsConfigured(cfg) {
return cfg.test == null || (Array.isArray(cfg.test) && cfg.test.every(t => typeof t.image === 'string'))
} Try / catch
err := r.Dev(ctx, out, dryRun)
if err != nil && strings.Contains(err.Error(), "test failed after first build") {
log.Warnf("tests failing: %v — fix or use --keep-running-on-failure", err)
} Prevention
- Keep container-test commands runnable locally
- Run `skaffold test` in CI before dev workflows
- Use --skip-tests temporarily only when tests are known-broken
- Ensure test images and fixtures are built/present
When it happens
Trigger: Dev(): after first build, r.Test fails; if not continuing via Opts.KeepRunningOnFailure the loop ends with err != nil and dev exits with this message.
Common situations: Unit tests failing on first run (missing test fixtures, wrong container-test command); container-structure-test failing; test image build issues.
Related errors
- exiting dev mode because first build failed: %w
- exiting dev mode because first render failed: %w
- configuration changed
- didn't sync any files
- failed to test: %w
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/c0dc0adb2c957b7b.
Report an issue: GitHub.