Docker run swift swift repl requires python 3

I think the docker images are not correctly up to date. It used to work (from Windows), but now I have to add "repl" to the examples given, and when I do that:

C:\src\swift $ docker run --cap-add sys_ptrace -it --rm swift swift repl
/usr/bin/lldb: error while loading shared libraries: libpython3.10.so.1.0: cannot open shared object file: No such file or directory

Am I doing something wrong or are these docker images no longer self-contained?

Edit: By the way, are Regex literals not supported on Linux? I can't seem to find a clear answer on it. I know it's not supported on release macOS and is on iOS.

3 Likes

Does it work if you start the container in privileged mode? Pretty sure the REPL needs that

Tried running:

docker run --privileged --cap-add sys_ptrace -it --rm swift swift repl
/usr/bin/lldb: error while loading shared libraries: libpython3.10.so.1.0: cannot open shared object file: No such file or directory

But still gives the same error. This is on Linux.

I created a container, attached to it and then got the same error inside the container when running swift repl.

I ran following commands inside the container:

apt update
apt install libpython3-dev

And then the error changed to:

root@ccdc861cb1c4:/# swift repl
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'lldb'
error: failed to launch REPL process: 'A' packet returned an error: 8

Then to get that lldb-error away I ran:

apt install python3-lldb
ln -s /usr/lib/llvm-14/lib/python3.10/dist-packages/lldb/* /usr/lib/python3/dist-packages/lldb/

This hint was fetched from: ModuleNotFoundError: No module named 'lldb.embedded_interpreter' · Issue #55575 · llvm/llvm-project · GitHub

Now I am left with:

root@ccdc861cb1c4:/# swift repl
error: failed to launch REPL process: 'A' packet returned an error: 8

And that went away when I ran the container like this:

docker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -it --name swiftfun swift /bin/bash

So, the swift docker image should be updated, right?

I had the same issue when trying to use the debugger from a docker container. I had to install libpython to get it to work.

Thank you for your response. It is exactly what I have done. I had to add "libpython3.10" to get it to work. I am wondering if the swift docker image needs to be updated to include this.

I opened the bug `swift repl` broken on Ubuntu images, appears to require libpython-dev · Issue #331 · apple/swift-docker · GitHub, referencing this thread. I'm not sure of the specific libraries that need to ideally get updated, but figured this would at least track it.

@bmontegani I made a PR that resolves the issue - installing the corrected version of libpython - and Mishal Shah merged it yesterday. Don't know how long it takes to flow out to updated docker images, but it should be resolved here pretty shortly.

1 Like