Snapcraft 7 in docker

Hi, I’ve been trying to upgrade my docker file to have snapcraft 7. I referenced this file to create the image:

FROM download-snap AS snapcraft-snap
RUN /tmp/ snapcraft 7.x/stable "$TARGETPLATFORM" /snap/snapcraft/current

RUN unlink /snap/snapcraft/current/usr/bin/python3
RUN ln -s /snap/snapcraft/current/usr/bin/python3.* /snap/snapcraft/current/usr/bin/python3
RUN echo /snap/snapcraft/current/lib/python3.*/site-packages >> /snap/snapcraft/current/usr/lib/python3/dist-packages/site-packages.pth

RUN mkdir -p /snap/bin
RUN echo "#!/bin/sh" > /snap/bin/snapcraft
RUN snap_version="$(awk '/^version:/{print $2}' /snap/snapcraft/current/meta/snap.yaml | tr -d \')" && echo "export SNAP_VERSION=\"$snap_version\"" >> /snap/bin/snapcraft
RUN echo 'exec "$SNAP/usr/bin/python3" "$SNAP/bin/snapcraft" "$@"' >> /snap/bin/snapcraft
RUN chmod +x /snap/bin/snapcraft

COPY --from=snapcraft-snap /snap/snapcraft/current /snap/snapcraft/current
COPY --from=snapcraft-snap /snap/bin/snapcraft /snap/bin/snapcraft

FROM base AS snapcraft
ENV SNAP="/snap/snapcraft/current"
ENV SNAP_NAME="snapcraft"
ENV PATH "${PATH}:/snap/bin:/snap/snapcraft/current/usr/bin:/usr/local/rust/bin"

I copied the relevant snippets from my code. And snapcraft itself runs. But the issue I am running is in the final stages of my build I am getting this error:

Executing parts lifecycle: build playlist
Executing action
:: + craftctl default
:: /bin/bash: line 51: craftctl: command not found
'override-build' in part 'playlist' failed with code 127.

How I can debug this issue? never seen anything similar before.

1 Like

Is there a craftctl in /snap/snapcraft/current/bin?

No, it’s not present there.

There is only craft-providers file.

root@922612a5a386:/snap/snapcraft/current/bin# ls -ll | grep craft
-rwxr-xr-x 1 root root     222 Mar 15 21:53 craft-providers

Is it supposed to be present there? I don’t see it on my lxc container where I have snapcraft installed with snap install?

My bad I actually meant /snap/snapcraft/current/libexec/snapcraft/, which Snapcraft 7 puts on its PATH

oh wow that was it, thanks. somehow I never checked the most basic thing. I grepped the code for craftctl instead of finding it by name. And grep found craft_providers file with a comment that it provides those commands :man_facepalming: Thanks!

1 Like