{"record":{"id":"53ec8036c93c49f0","repo":"GoogleContainerTools/skaffold","slug":"image-q-context-q-is-not-a-directory","errorCode":null,"errorMessage":"image %q context %q is not a directory","messagePattern":"image %q context %q is not a directory","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/runner/build.go","lineNumber":160,"sourceCode":"\t\t\tTag:         tags[artifact.ImageName],\n\t\t\tRuntimeType: artifact.RuntimeType,\n\t\t})\n\t}\n\n\treturn bRes\n}\n\nfunc CheckWorkspaces(artifacts []*latest.Artifact) error {\n\tfor _, a := range artifacts {\n\t\tif a.Workspace != \"\" {\n\t\t\tif info, err := os.Stat(a.Workspace); err != nil {\n\t\t\t\t// err could be permission-related\n\t\t\t\tif os.IsNotExist(err) {\n\t\t\t\t\treturn fmt.Errorf(\"image %q context %q does not exist\", a.ImageName, a.Workspace)\n\t\t\t\t}\n\t\t\t\treturn fmt.Errorf(\"image %q context %q: %w\", a.ImageName, a.Workspace, err)\n\t\t\t} else if !info.IsDir() {\n\t\t\t\treturn fmt.Errorf(\"image %q context %q is not a directory\", a.ImageName, a.Workspace)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n","sourceCodeStart":142,"sourceCodeEnd":166,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/runner/build.go#L142-L166","documentation":"CheckWorkspaces checks that each artifact's build context is a directory. This error is returned when os.Stat succeeds but the workspace path resolves to a file, symlink-to-file, socket, etc. — anything that is not a directory. Build contexts must be directories.","triggerScenarios":"A skaffold.yaml artifact's `context`/`workspace` points at a regular file (e.g. `context: ./Dockerfile` or `context: ./config.yaml`) instead of a directory.","commonSituations":"Typo in the context path so it accidentally names a file; pointing at a tarball or single-file build input; a file replacing a directory after a refactor or git operation.","solutions":["Change the artifact `context:` in skaffold.yaml to point to the directory containing the Dockerfile","Verify with `ls -la <path>` that the target is a directory (`d` in the mode column)","If you intended a single-file build input, move it into a context directory and reference that directory"],"exampleFix":"// before (skaffold.yaml)\nbuild:\n  artifacts:\n    - image: app\n      context: ./deploy/Dockerfile\n// after\nbuild:\n  artifacts:\n    - image: app\n      context: ./deploy   # directory containing the Dockerfile","handlingStrategy":"validation","validationCode":"const info = await fs.promises.stat(artifact.Workspace)\nif (!info.isDirectory()) {\n  throw new Error(`artifact context must be a directory, got: ${artifact.Workspace}`)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always point artifact `context:` at the directory containing the Dockerfile","Validate skaffold.yaml paths with a linter before running builds","Watch for refactors that replace context directories with single files"],"tags":["build","config","skaffold-yaml"],"backgroundTag":"invalid-build-context","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"}