Description of problem: Trying to use Visual Studio Code to debug a swift program. The code extension CodeLLDB is trying to use LLDB's python to analyze the application state. It uses the following command in LLDB to determine configuration: /usr/libexec/swift-lldb/lldb -b -O 'script print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeLLDBShlibDir).fullpath + "!>");print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeSupportExecutableDir).fullpath + "!>")' The output from /usr/libexec/swift-lldb/lldb is: (lldb) script print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeLLDBShlibDir).fullpath + "!>");print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeSupportExecutableDir).fullpath + "!>") Traceback (most recent call last): File "<string>", line 1, in <module> File "/usr/lib64/python3.7/site-packages/lldb/__init__.py", line 1081, in <module> eSectionTypeDWARFDebugTypesDwo = _lldb.eSectionTypeDWARFDebugTypesDwo AttributeError: module '_lldb' has no attribute 'eSectionTypeDWARFDebugTypesDwo' Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'run_one_line' is not defined Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'run_one_line' is not defined Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'run_one_line' is not defined Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'run_one_line' is not defined Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'run_one_line' is not defined Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'run_one_line' is not defined error: python failed attempting to evaluate 'print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeLLDBShlibDir).fullpath + "!>");print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeSupportExecutableDir).fullpath + "!>")' The system package lldb returns: $ /usr/bin/lldb -b -O 'script print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeLLDBShlibDir).fullpath + "!>");print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeSupportExecutableDir).fullpath + "!>")' (lldb) script print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeLLDBShlibDir).fullpath + "!>");print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeSupportExecutableDir).fullpath + "!>") <!/usr/lib64!> <!/usr/bin!> Version-Release number of selected component (if applicable): swift-lang-5.1.5-0.3.20200305git30c042c.fc31.x86_64 How reproducible: Every time Steps to Reproduce: 1. Install swift-lang 2. Run: /usr/libexec/swift-lldb/lldb -b -O 'script print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeLLDBShlibDir).fullpath + "!>");print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeSupportExecutableDir).fullpath + "!>")' Actual results: Error shown above Expected results: <!/usr/lib/swift!> <!/usr/libexec/swift-lldb!> Additional info: I've filed this ticket against the VSCode extension here: https://github.com/vadimcn/vscode-lldb/issues/281 before realizing this was a problem with the Fedora package. More information may be there.
Hey Ben- Do you know if this worked before 5.1.5?
Sorry, I only tried this for the first time last week. If you want, I can try to download an old package and try.
Might be useful. FYI Apple released Swift 5.2 yesterday and I'm trying to get that working with Fedora (it has been surprisingly difficult); I'll look into this and see if it's a simple fix, otherwise are you okay waiting for 5.2?
So, as an update: I tested the line above using an official Ubuntu version and, yes, it does work. Funny enough, using the official Ubuntu 5.2 release it does *not* work; it gives the same error. Still looking into it.
As a *further* update, I see the issue; I am not packaging the "python2.7" directory which includes the lldb module that causes the error. This is currently hard-coded to live in /usr/lib so that's a problem. ;) Also, the reason why it doesn't work in 5.2 is because, surprise, they don't include the "python2.7" directory at all. This is all checked against the official Ubuntu versions downloaded from https://swift.org. They also started writing some header files to /usr/local/include for the IndexStore; I have to evaluate how this is going to work as a package going forward.
Ugh. I'm shocked by a lot of this: the hard coded paths, the inability to scan the paths from a path search, and the reliance on python 2.7. I was hoping this was a simple fix! :)
FYI I asked the packaging committee about changing how Swift is packaged (https://pagure.io/packaging-committee/issue/966); hopefully it will make using Swift, even in VSCode, a lot easier. I've been testing my proposal and so far it's been working well. Just keeping you informed about what's going on.
Hey Ben- FYI I submitted 5.2.1 for testing. I reorganized the package and Sourcekit-LSP worked with NeoVim right away; dunno what the plugin for VSCode will say about it, but in my testing everything has been working well and is a lot easier to maintain and don't have to deal with modifying code to look in *other* hard-coded places than the ones it's already looking for. ;) Here's the links to the builds if you want to give it a go: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2020-42b57fbd27 https://bodhi.fedoraproject.org/updates/FEDORA-2020-aae36b1366 https://bodhi.fedoraproject.org/updates/FEDORA-2020-97a74de7d6 https://bodhi.fedoraproject.org/updates/FEDORA-2020-579503009b
That's fantastic! I'll test them today.
The test code still didn't work. I don't see the python2.7 directory in the swift-lang package. $ /usr/libexec/swift/bin/lldb -b -O 'script print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeLLDBShlibDir).fullpath + "!>");print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeSupportExecutableDir).fullpath + "!>")'(lldb) script print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeLLDBShlibDir).fullpath + "!>");print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeSupportExecutableDir).fullpath + "!>") Traceback (most recent call last): File "<string>", line 1, in <module> File "/usr/lib64/python3.7/site-packages/lldb/__init__.py", line 14097, in <module> target = SBTarget() File "/usr/lib64/python3.7/site-packages/lldb/__init__.py", line 9443, in __init__ _lldb.SBTarget_swiginit(self, _lldb.new_SBTarget(*args)) AttributeError: module '_lldb' has no attribute 'SBTarget_swiginit' Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'run_one_line' is not defined Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'run_one_line' is not defined Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'run_one_line' is not defined Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'run_one_line' is not defined Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'run_one_line' is not defined Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'run_one_line' is not defined error: python failed attempting to evaluate 'print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeLLDBShlibDir).fullpath + "!>");print("<!" + lldb.SBHostOS.GetLLDBPath(lldb.ePathTypeSupportExecutableDir).fullpath + "!>")'
Hey Ben- Right, 5.2.1 doesn't include a Python runtime at all; I think the onus will be on the plugin author to update his code; I also checked the latest 5.3 build on Ubuntu and it seems a "python" directory within the Swift toolchain has been removed going forward. FWIW, NeoVim works great with the SourceKit LSP in 5.2.1.
It works! I have these settings in vscode's settings.json file: { "telemetry.enableTelemetry": false, "sde.languageServerMode": "sourcekit-lsp", "sourcekit-lsp.serverPath": "/usr/bin/sourcekit-lsp", "swift.languageServerPath": "/usr/bin/langserver-swift", "[swift]": {}, "lldb.executable": "/usr/libexec/swift/bin/lldb", "lldb.libpython": "/lib64/libpython3.7m.so.1.0", "lldb.library": "/usr/libexec/swift/lib/liblldb.so.7.0.0svn", "lldb.adapterEnv": { "LLDB_DEBUGSERVER_PATH": "/usr/libexec/swift/bin/lldb-server" } } It looks like /usr/bin/langserver-swift no longer exists in the swift-lang package though it doesn't seem to cause any issues.
Awesome! Okay to close this bug?
sure.