Swift repl: no module named lldb

$ ~/.swiftenv/versions/5.7-RELEASE/usr/bin/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

i understand the REPL has never worked on the nightlies, but i at least expected it to work out of the box in the 5.7 release toolchain…

same issues
workaround method is install lldb
and make soft link dist-packages

sudo ln -s /usr/lib/llvm-14/lib/python3.10/dist-packages /usr/local/lib/swift-5.7-RELEASE-ubuntu22.04/usr/lib/python3/dist-packages
1 Like

@taylorswift are you seeing this on Linux?

I have the same issue. On Ubuntu 18.04 in my case.

Swift compiler hasn't shipped with LLDB Python binding since 5.6.x. I just checked 5.7 package, no LLDB Python binding neither. You have to compile yourself. However, repl doesn't require Python LLDB binding before, so I am unsure why it becomes an issue and why @Kila2 's workaround would work.

yes, on an Amazon Linux 2 docker. i originally thought it was a docker issue because of a missing --cap-add SYS_PTRACE, but that did not fix the issue.

it seems… unhealthy (to say the least) for swift to be shipping a broken playground by default?

1 Like

FWIW, I tested it with 5.7-RELEASE on Fedora 36 and it works properly.

I am not sure if it is REPL doesn't work out of box (as I said, Python LLDB binding is not required for 5.6's REPL I tested) or there are some setups in your .lldbinit somehow requires Python LLDB binding though. Thus, I am not in authority to say it is a broken playground by default.

However, without Python LLDB binding I believe that does make VSCode debugger integration stranger on Linux (I don't use that though). It also makes my Jupyter notebook usage harder, but I guess I am on my own there anyway.

Installing the python3-lldb-13 package helped me.