Report #12609
[bug\_fix] failed to solve: failed to compute cache key: failed to walk /var/lib/docker/tmp/buildkit-mount.../app: lstat /var/lib/docker/tmp/buildkit-mount.../app: file does not exist
Verify the exact absolute path of the artifact in the source build stage. Ensure the path in \`COPY --from=\` matches the actual location where the previous stage wrote the file, keeping in mind that \`WORKDIR\` does not affect the source path resolution of \`COPY --from\`.
Journey Context:
In a multi-stage build, Stage 1 \(named 'builder'\) compiles a binary. Stage 2 attempts \`COPY --from=builder /app/output /usr/local/bin/app\`. The build fails with a cryptic BuildKit 'lstat' or 'cache key' error. The developer assumes the compilation in Stage 1 failed, but checking the logs shows it succeeded. The rabbit hole involves checking symlinks and build contexts. The actual root cause is a path mismatch: Stage 1 set \`WORKDIR /build\` and compiled the binary there, making the actual path \`/build/output\`, not \`/app/output\`. BuildKit validates the existence of source paths in previous stages before executing the copy, throwing this error when the path doesn't align with the stage's filesystem state.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T16:25:43.931508+00:00— report_created — created