RUN heredoc after ARG doesn't invalidate layer
Description
This seems to be related to #5225, which has been fixed. However, a slight change with an ARG before of the heredoc still does not invalidate the cache.
Steps to reproduce the issue:
$ echo -e "FROM alpine:latest\nARG foo=bar\nRUN <<EOF\necho $(date '+%s.%N')\nEOF" | buildah build --layers -
STEP 1/3: FROM alpine:latest
STEP 2/3: ARG foo=bar
--> Using cache 6e4725bb02033874e465c3f1be1e93cb71baa3b28ae2f7a4ce4454e33fceea6d
--> 6e4725bb0203
STEP 3/3: RUN <<EOF (echo 1722282857.543348323)
1722282857.543348323
COMMIT
--> e869bffc8379
e869bffc83792e1b57f098ed4b0e9e88100b15e04e3e49dd9d9d33016a8841ea
$ echo -e "FROM alpine:latest\nARG foo=bar\nRUN <<EOF\necho $(date '+%s.%N')\nEOF" | buildah build --layers -
STEP 1/3: FROM alpine:latest
STEP 2/3: ARG foo=bar
--> Using cache 6e4725bb02033874e465c3f1be1e93cb71baa3b28ae2f7a4ce4454e33fceea6d
--> 6e4725bb0203
STEP 3/3: RUN <<EOF (echo 1722282865.468415429)
--> Using cache e869bffc83792e1b57f098ed4b0e9e88100b15e04e3e49dd9d9d33016a8841ea
--> e869bffc8379
e869bffc83792e1b57f098ed4b0e9e88100b15e04e3e49dd9d9d33016a8841ea
Describe the results you received:
The second run reused the cache even though the heredoc content is different.
Describe the results you expected:
The second run should rebuild the layer.
Output of buildah version:
Version: 1.36.0
Go Version: go1.22.4
Image Spec: 1.1.0
Runtime Spec: 1.2.0
CNI Spec: 1.0.0
libcni Version: v1.1.2
image Version: 5.31.0
Git Commit: 6ceba8838d331eb26378cb37d9fc8ba98939aa92
Built: Fri Jun 7 02:48:31 2024
OS/Arch: linux/amd64
BuildPlatform: linux/amd64
A friendly reminder that this issue had no activity for 30 days.
Confirmed, @flouthoc mind looking at this one?
I'll take a look at this, thanks for reporting.
A friendly reminder that this issue had no activity for 30 days.
Oh man I got burned by this one just now...
Oh man I got burned by this one just now...
lol, you and me both...
This is the reason for the --no-cache in https://github.com/containers/composefs-rs/blob/main/examples/uki/build
I think maybe the ARG part is a red herring. For me it fails to invalidate regardless if I use the ARG or not
A friendly reminder that this issue had no activity for 30 days.
I've also been encountering this. I was really hoping to avoid using && chains but I guess that's the workaround for now.