{"record":{"id":"1517f7d80e3038d6","repo":"GoogleContainerTools/skaffold","slug":"retrieving-working-dir-for-q-w","errorCode":null,"errorMessage":"retrieving working dir for %q: %w","messagePattern":"retrieving working dir for %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/sync/sync.go","lineNumber":88,"sourceCode":"\tswitch {\n\tcase len(a.Sync.Manual) > 0:\n\t\treturn syncItem(ctx, a, tag, e, a.Sync.Manual, cfg)\n\n\tcase a.Sync.Auto != nil:\n\t\treturn autoSyncItem(ctx, a, tag, e, cfg)\n\n\tcase len(a.Sync.Infer) > 0:\n\t\treturn inferredSyncItem(ctx, a, tag, e, cfg)\n\n\tdefault:\n\t\treturn nil, nil\n\t}\n}\n\nfunc syncItem(ctx context.Context, a *latest.Artifact, tag string, e filemon.Events, syncRules []*latest.SyncRule, cfg docker.Config) (*Item, error) {\n\tcontainerWd, err := WorkingDir(ctx, tag, cfg)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"retrieving working dir for %q: %w\", tag, err)\n\t}\n\n\ttoCopy, err := intersect(ctx, a.Workspace, containerWd, syncRules, append(e.Added, e.Modified...))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"intersecting sync map and added, modified files: %w\", err)\n\t}\n\n\ttoDelete, err := intersect(ctx, a.Workspace, containerWd, syncRules, e.Deleted)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"intersecting sync map and deleted files: %w\", err)\n\t}\n\n\t// Something went wrong, don't sync, rebuild.\n\tif toCopy == nil || toDelete == nil {\n\t\treturn nil, nil\n\t}\n\n\treturn &Item{Image: tag, Artifact: a, Copy: toCopy, Delete: toDelete}, nil","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/sync/sync.go#L70-L106","documentation":"`syncItem` wraps failures from `WorkingDir(ctx, tag, cfg)`, which inspects the built image (e.g. via docker inspect) to learn its working directory. The error means skaffold could not retrieve the container working dir, so relative sync paths inside the container cannot be computed and the file sync item cannot be created.","triggerScenarios":"Calling `syncItem` (via `NewItem` or `autoSyncItem`) with a tag whose image no longer exists locally, a docker daemon that is unreachable, or an image without a resolvable Config.WorkingDir due to registry/inspect API errors.","commonSituations":"Docker image pruned between build and sync so `docker inspect` fails; DOCKER_HOST pointing at an unreachable remote daemon; registry authentication errors when the image must be inspected remotely; corrupted image metadata.","solutions":["Verify the image with the given tag exists (docker images) and rebuild if it was pruned.","Check DOCKER_HOST / docker daemon connectivity (docker info).","Re-authenticate with the registry if image inspection requires remote metadata access.","Trigger a full rebuild/redeploy to get a fresh, inspectable image tag."],"exampleFix":"// before\nexport DOCKER_HOST=tcp://unreachable:2375\nskaffold dev // retrieving working dir: cannot connect\n// after\nexport DOCKER_HOST=unix:///var/run/docker.sock\nskaffold dev // inspect succeeds","handlingStrategy":"validation","validationCode":"if _, _, err := exec.Command(\"docker\", \"image\", \"inspect\", tag).CombinedOutput(); err != nil {\n  return fmt.Errorf(\"image %s missing locally; rebuild before sync\", tag)\n}","typeGuard":null,"tryCatchPattern":"item, err := sync.NewItem(ctx, artifact, events, builds, cfg)\nif err != nil {\n  if strings.Contains(err.Error(), \"retrieving working dir\") {\n    log.Printf(\"cannot inspect image (%v); falling back to rebuild\", err)\n    return triggerRebuild(artifact)\n  }\n  return err\n}","preventionTips":["Disable aggressive image pruning (docker image prune) during dev sessions.","Verify DOCKER_HOST points to a reachable daemon before running dev.","docker login to any private registries used by the image.","Trigger a rebuild/redeploy whenever image metadata inspection fails."],"tags":["docker","file-sync","image-inspect","go"],"backgroundTag":"docker-image-inspect-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"}