Bash: ../usr/bin/python3.10: No such file or directory

Hi,

I am trying to build a snapcraft docker image.

Manually download the snapcraft snap

FROM ubuntu:22.04

RUN curl -L $(curl -H 'X-Ubuntu-Series: 16' -H 'X-Ubuntu-Architecture: arm64' 'https://api.snapcraft.io/api/v1/snaps/details/snapcraft?channel='$RISK | jq '.download_url' -r) --output snapcraft.snap
RUN mkdir -p /snap/snapcraft
RUN unsquashfs -d /snap/snapcraft/current snapcraft.snap
cd /snap/snapcraft/current/bin
root@d7d7f102b2a7:/snap/snapcraft/current/bin# ls -l python*
lrwxrwxrwx 1 root root  7 Mar 15 21:34 python -> python3
lrwxrwxrwx 1 root root 21 Mar 15 21:36 python3 -> ../usr/bin/python3.10
lrwxrwxrwx 1 root root  7 Mar 15 21:34 python3.10 -> python3
root@d7d7f102b2a7:/snap/snapcraft/current/bin# ../usr/bin/python3.10 
bash: ../usr/bin/python3.10: No such file or directory
root@d7d7f102b2a7:/snap/snapcraft/current/bin# ./python3 ./snapcraft
bash: ./python3: No such file or directory

How do I run snapcraft in a container ?

The strange thing is it works in Ubuntu 22.04 desktop, using the same steps.

ubuntu@ubuntu:/snap/s/current/bin$ ./python3 ./snapcraft -V
snapcraft 8.0.5  

I suspect it works on your desktop because you have the core22 snap installed.

In your docker or whatever container, you don’t.

The python3.10 binary in /snap/snapcraft/current/usr/bin is dynamically linked to /snap/core22/current/lib64/ld-linux-x86-64.so.2.

I can reproduce your issue with a lxd container (in which I ripped out all the snaps, and the snapd deb, then rm’ed most of /snap). I then unpacked the snapcraft snap as you did.

root@test:/snap/snapcraft/current/usr/bin# file python3.10 
python3.10: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /snap/core22/current/lib64/ld-linux-x86-64.so.2, BuildID[sha1]=08d0fd215a9a98d5333fda7e5a9a46c923148415, for GNU/Linux 3.2.0, stripped
root@test:/snap/snapcraft/current/usr/bin# 

If you grab the core22 snap, and do what you did with snapcraft, unpacking it into /snap/core22/current - you might have some success. I did.

root@test:/snap/snapcraft/current/bin# ./python3 ./snapcraft --version
snapcraft 8.0.5   
1 Like

Thank you so much! :wave:

1 Like