{"record":{"id":"dec4d4f4f5e356cf","repo":"GoogleContainerTools/skaffold","slug":"exiting-dev-mode-because-initializing-sync-state-f","errorCode":null,"errorMessage":"exiting dev mode because initializing sync state failed: %w","messagePattern":"exiting dev mode because initializing sync state failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/runner/dev.go","lineNumber":466,"sourceCode":"\tif err := r.monitor.Register(\n\t\tfunc() ([]string, error) { return []string{r.runCtx.ConfigurationFile()}, nil },\n\t\tfunc(filemon.Events) { r.changeSet.Reload() },\n\t); err != nil {\n\t\tevent.DevLoopFailedWithErrorCode(r.devIteration, proto.StatusCode_DEVINIT_REGISTER_CONFIG_DEP, err)\n\t\teventV2.TaskFailed(constants.DevLoop, err)\n\t\tendTrace()\n\t\treturn fmt.Errorf(\"watching skaffold configuration %q: %w\", r.runCtx.ConfigurationFile(), err)\n\t}\n\n\tlog.Entry(ctx).Infoln(\"List generated in\", timeutil.Humanize(time.Since(start)))\n\tlog.Entry(ctx).Infoln(\"Dev loop completed in\", timeutil.Humanize(time.Since(devStart)))\n\n\t// Init Sync State\n\tif err := sync.Init(ctx, artifacts); err != nil {\n\t\tevent.DevLoopFailedWithErrorCode(r.devIteration, proto.StatusCode_SYNC_INIT_ERROR, err)\n\t\teventV2.TaskFailed(constants.DevLoop, err)\n\t\tendTrace()\n\t\treturn fmt.Errorf(\"exiting dev mode because initializing sync state failed: %w\", err)\n\t}\n\n\toutput.Yellow.Fprintln(out, \"Press Ctrl+C to exit\")\n\n\tevent.DevLoopComplete(r.devIteration)\n\teventV2.TaskSucceeded(constants.DevLoop)\n\tendTrace()\n\tr.devIteration++\n\treturn r.listener.WatchForChanges(ctx, out, func() error {\n\t\treturn r.doDev(ctx, out)\n\t})\n}\n\n// graph represents the artifact graph\ntype devGraph map[string][]*latest.Artifact\n\n// getTransposeGraph builds the transpose of the graph represented by the artifacts slice, with edges directed from required artifact to the dependent artifact.\nfunc getTransposeGraph(artifacts []*latest.Artifact) devGraph {","sourceCodeStart":448,"sourceCodeEnd":484,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/runner/dev.go#L448-L484","documentation":"Dev() initializes the file-sync state (sync.Init) that tracks which changed files can be hot-synced into running containers. If initialization fails, Skaffold emits SYNC_INIT_ERROR and exits dev mode with 'exiting dev mode because initializing sync state failed'.","triggerScenarios":"`sync.Init(ctx, artifacts)` returns an error while setting up sync state for the artifact set — e.g. a `sync:` stanza in an artifact has invalid rules, or enumerating syncable files for an artifact fails.","commonSituations":"Malformed `sync:` config in skaffold.yaml (bad glob patterns or manual/auto/infer mixing); artifact build contexts unreadable during sync-rule evaluation; schema incompatibilities after upgrading skaffold versions.","solutions":["Review the wrapped error and fix the `sync:` rules for the offending artifact in skaffold.yaml","Validate globs in the sync config are well-formed and match files in the build context","Run `skaffold config` / `skaffold dev --verbosity=debug` to pinpoint which artifact fails","Remove the sync stanza to fall back to rebuild-on-change if sync isn't needed"],"exampleFix":"// before\nartifacts:\n  - image: app\n    sync:\n      manual:\n        - src: '[['   # invalid glob\n          dest: .\n// after\nartifacts:\n  - image: app\n    sync:\n      manual:\n        - src: 'src/**/*.js'\n          dest: .","handlingStrategy":"validation","validationCode":"// validate sync globs before dev\nfor _, a := range cfg.Build.Artifacts {\n    for _, r := range a.Sync.Manual {\n        if _, err := filepath.Match(strings.Trim(r.Src, \"*\"), r.Src); r.Src == \"\" {\n            return fmt.Errorf(\"artifact %q has empty sync src\", a.ImageName)\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep sync globs simple and test them against real files","Prefer `infer` or `auto` sync over hand-written globs when unsure","Validate skaffold.yaml against the schema after upgrades","Remove sync stanzas for artifacts that don't need hot reload"],"tags":["skaffold","sync","dev-loop","config"],"backgroundTag":"sync-init-failed","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"}