{"record":{"id":"f08af1f9685c00ce","repo":"GoogleContainerTools/skaffold","slug":"getting-relative-tar-paths-w","errorCode":null,"errorMessage":"getting relative tar paths: %w","messagePattern":"getting relative tar paths: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/docker/context.go","lineNumber":31,"sourceCode":"See the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage docker\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\t\"path/filepath\"\n\n\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util\"\n)\n\nfunc CreateDockerTarContext(ctx context.Context, w io.Writer, buildCfg BuildConfig, cfg Config) error {\n\tpaths, err := GetDependenciesCached(ctx, buildCfg, cfg)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting relative tar paths: %w\", err)\n\t}\n\n\tvar p []string\n\tfor _, path := range paths {\n\t\tp = append(p, filepath.Join(buildCfg.workspace, path))\n\t}\n\n\tif err := util.CreateTar(ctx, w, buildCfg.workspace, p); err != nil {\n\t\treturn fmt.Errorf(\"creating tar gz: %w\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":13,"sourceCodeEnd":45,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/docker/context.go#L13-L45","documentation":"CreateDockerTarContext wraps any failure from GetDependenciesCached with 'getting relative tar paths'. When Skaffold builds a tar.gz Docker build context it must first compute the dependency file list (which requires resolving and parsing the Dockerfile); a failure anywhere in that dependency resolution surfaces here. The root cause is always in the wrapped error — commonly a missing or unreadable Dockerfile.","triggerScenarios":"Calling CreateDockerTarContext where GetDependenciesCached fails: NormalizeDockerfilePath can't find the Dockerfile, or the Dockerfile can't be parsed for dependencies (bad COPY/ADD sources, missing files).","commonSituations":"dockerfilePath points to a non-existent file; workspace path is wrong; Dockerfile references COPY sources that don't exist; .dockerignore handling fails; cached dependency error replayed for the artifact.","solutions":["Read the wrapped error: it names the real failure (e.g. Dockerfile not found vs missing COPY source).","Verify dockerfilePath resolves from the workspace: check the artifact's 'docker.dockerfile' value and that the file exists.","Confirm all COPY/ADD sources in the Dockerfile exist relative to the workspace.","Check that the workspace path is correct and readable from where Skaffold runs.","If a stale cache entry is suspected, restart Skaffold to clear the in-memory dependency cache."],"exampleFix":"// before\nbuild:\n  artifacts:\n    - image: app\n      docker:\n        dockerfile: Dockerfile.prod   # file does not exist\n// after\nbuild:\n  artifacts:\n    - image: app\n      docker:\n        dockerfile: Dockerfile        # exists at workspace root","handlingStrategy":"try-catch","validationCode":"ws := buildCfg.workspace\ndf := buildCfg.dockerfilePath\nif df == \"\" {\n    df = \"Dockerfile\"\n}\nif _, err := os.Stat(filepath.Join(ws, df)); err != nil {\n    return fmt.Errorf(\"Dockerfile %s not found in workspace %s: %w\", df, ws, err)\n}","typeGuard":"func dockerfileExists(ws, dockerfilePath string) bool {\n    if dockerfilePath == \"\" {\n        dockerfilePath = \"Dockerfile\"\n    }\n    info, err := os.Stat(filepath.Join(ws, dockerfilePath))\n    return err == nil && !info.IsDir()\n}","tryCatchPattern":"err := CreateDockerTarContext(ctx, w, buildCfg, cfg)\nif err != nil {\n    if strings.Contains(err.Error(), \"getting relative tar paths\") {\n        return fmt.Errorf(\"build context dependency resolution failed — check the Dockerfile path and COPY sources: %w\", err)\n    }\n    return err\n}","preventionTips":["Stat the Dockerfile (workspace + dockerfilePath) before building the tar context.","Verify every COPY/ADD source in the Dockerfile exists under the workspace.","Keep .dockerignore in sync with the workspace layout.","Use 'skaffold build --dry-run'-style checks or 'skaffold dev' early to catch path errors."],"tags":["docker","build-context","tar"],"backgroundTag":"dockerfile-dependency-resolution-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"}