{"record":{"id":"5abbb95f5106bbc8","repo":"GoogleContainerTools/skaffold","slug":"exiting-dev-mode-because-first-build-failed-w","errorCode":null,"errorMessage":"exiting dev mode because first build failed: %w","messagePattern":"exiting dev mode because first build failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/runner/dev.go","lineNumber":284,"sourceCode":"\t})\n\n\tdevStart := time.Now()\n\t// First build\n\tvar err error\n\tbRes, err := r.Build(ctx, out, artifacts)\n\tfor ; err != nil && r.runCtx.Opts.KeepRunningOnFailure; bRes, err = r.Build(ctx, out, artifacts) {\n\t\tlog.Entry(ctx).Warnf(\"Failed to build artifacts: %v, please fix the error and press any key to continue.\", err)\n\t\terrT := term.WaitForKeyPress()\n\t\tif errT != nil {\n\t\t\treturn errT\n\t\t}\n\t}\n\n\tif err != nil {\n\t\tevent.DevLoopFailedInPhase(r.devIteration, constants.Build, err)\n\t\teventV2.TaskFailed(constants.DevLoop, err)\n\t\tendTrace()\n\t\treturn fmt.Errorf(\"exiting dev mode because first build failed: %w\", err)\n\t}\n\t// First test\n\tif r.runCtx.IsTestPhaseActive() {\n\t\terr = r.Test(ctx, out, bRes)\n\t\tfor ; err != nil && r.runCtx.Opts.KeepRunningOnFailure; err = r.Test(ctx, out, bRes) {\n\t\t\tlog.Entry(ctx).Warnf(\"Failed to run tests :%v, please fix the error and press any key to continue.\", err)\n\t\t\terrT := term.WaitForKeyPress()\n\t\t\tif errT != nil {\n\t\t\t\treturn errT\n\t\t\t}\n\t\t}\n\t\tif err != nil {\n\t\t\tevent.DevLoopFailedInPhase(r.devIteration, constants.Build, err)\n\t\t\teventV2.TaskFailed(constants.DevLoop, err)\n\t\t\tendTrace()\n\t\t\treturn fmt.Errorf(\"exiting dev mode because test failed after first build: %w\", err)\n\t\t}\n\t}","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/runner/dev.go#L266-L302","documentation":"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.","triggerScenarios":"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.","commonSituations":"Dockerfile syntax error or missing base image; failing compile step; missing build dependencies on first run of `skaffold dev`; registry authentication failure.","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"],"exampleFix":"// before\nFROM node:19-typo\n// after\nFROM node:19-alpine","handlingStrategy":"try-catch","validationCode":"// verify build inputs before dev\ndockerfile && require('fs').existsSync(dockerfile) || exit('missing Dockerfile')\n// and pre-warm: skaffold build --dry-run","typeGuard":"function canStartDev(artifacts) {\n  return artifacts.every(a => a.dockerArtifact == null || typeof a.dockerArtifact.dockerfile === 'string')\n}","tryCatchPattern":"err := r.Dev(ctx, out, dryRun)\nif err != nil && strings.Contains(err.Error(), \"first build failed\") {\n    log.Fatalf(\"fix build before dev: %v\", err) // do not retry blindly\n}","preventionTips":["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"],"tags":["dev-loop","build","fatal"],"backgroundTag":"initial-build-failure","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}