GoogleContainerTools/skaffold · error
getting relative tar paths: %w
Error message
getting relative tar paths: %w
What it means
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.
Source
Thrown at pkg/skaffold/docker/context.go:31
See the License for the specific language governing permissions and
limitations under the License.
*/
package docker
import (
"context"
"fmt"
"io"
"path/filepath"
"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util"
)
func CreateDockerTarContext(ctx context.Context, w io.Writer, buildCfg BuildConfig, cfg Config) error {
paths, err := GetDependenciesCached(ctx, buildCfg, cfg)
if err != nil {
return fmt.Errorf("getting relative tar paths: %w", err)
}
var p []string
for _, path := range paths {
p = append(p, filepath.Join(buildCfg.workspace, path))
}
if err := util.CreateTar(ctx, w, buildCfg.workspace, p); err != nil {
return fmt.Errorf("creating tar gz: %w", err)
}
return nil
}
View on GitHub (pinned to a1189de023)
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.
Example fix
// before
build:
artifacts:
- image: app
docker:
dockerfile: Dockerfile.prod # file does not exist
// after
build:
artifacts:
- image: app
docker:
dockerfile: Dockerfile # exists at workspace root Defensive patterns
Strategy: try-catch
Validate before calling
ws := buildCfg.workspace
df := buildCfg.dockerfilePath
if df == "" {
df = "Dockerfile"
}
if _, err := os.Stat(filepath.Join(ws, df)); err != nil {
return fmt.Errorf("Dockerfile %s not found in workspace %s: %w", df, ws, err)
} Type guard
func dockerfileExists(ws, dockerfilePath string) bool {
if dockerfilePath == "" {
dockerfilePath = "Dockerfile"
}
info, err := os.Stat(filepath.Join(ws, dockerfilePath))
return err == nil && !info.IsDir()
} Try / catch
err := CreateDockerTarContext(ctx, w, buildCfg, cfg)
if err != nil {
if strings.Contains(err.Error(), "getting relative tar paths") {
return fmt.Errorf("build context dependency resolution failed — check the Dockerfile path and COPY sources: %w", err)
}
return err
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- creating docker context: %w
- creating docker context: %w
- creating tar gz: %w
- loading image into docker daemon: %w
- %q running container image %q errored during run with status
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/f08af1f9685c00ce.
Report an issue: GitHub.