Bug 2361538 - Cannot use lldb when in a virtual envrionment.
Summary: Cannot use lldb when in a virtual envrionment.
Keywords:
Status: CLOSED COMPLETED
Alias: None
Product: Fedora
Classification: Fedora
Component: lldb
Version: 42
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Nikita Popov
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2025-04-21 22:45 UTC by Ezike Ebuka
Modified: 2025-07-10 07:53 UTC (History)
10 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2025-07-10 07:53:11 UTC
Type: Bug
Embargoed:
npopov: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker FC-1611 0 None None None 2025-04-22 08:50:32 UTC

Description Ezike Ebuka 2025-04-21 22:45:26 UTC
Description of problem:
LLDB does not working in a virtual environment.


Version-Release number of selected component (if applicable):
20.1 fedora 42. 


How reproducible:
$ python -m venv venv
$ source ./venv/bin/activate
$ lldb 


Actual results:
LLDB starts with python error of missing modules 

```sh
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'lldb.embedded_interpreter'
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
Traceback (most recent call last):
  File "/home/da-viper/Dev/contribute/llvm-project/llvm/utils/lldbDataFormatters.py", line 14, in __lldb_init_module
    debugger.HandleCommand("type category define -e llvm -l c++")
    ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'SwigPyObject' object has no attribute 'HandleCommand'
swig/python detected a memory leak of type 'lldb::SBDebugger *', no destructor found.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'lldb' is not defined
```

Expected results: LLDB lauches fine. 


Additional info: 
After reading the LLVM.spec file i think this is caused by the line 
```
%if %{without compat_build}
	
# Move python package out of llvm prefix.
	
mkdir -p %{buildroot}%{python3_sitearch}
	
mv %{buildroot}%{install_prefix}/%{_lib}/python%{python3_version}/site-packages/lldb %{buildroot}/%{python3_sitearch}
	
rmdir %{buildroot}%{install_prefix}/%{_lib}/python%{python3_version}/site-packages
	
rmdir %{buildroot}%{install_prefix}/%{_lib}/python%{python3_version}
```
Since it is moved to the default site packages on the OS, when we create a virtual environment the site packages that is checked is overridden, Then it will not find the required module. 

file spec link https://src.fedoraproject.org/rpms/llvm/blob/rawhide/f/llvm.spec

This is not in set in Fedora 41 branch

Comment 1 Nikita Popov 2025-04-22 07:33:37 UTC
I think the location on f41 is the same, it's just that it gets there in a different way. On f41 it was directly installed there, on f42 we first install to a different path and then move it. The lldb binary itself will be in a different location though, maybe that makes a difference?

Comment 2 Tulio Magno Quites Machado Filho 2025-04-25 14:07:56 UTC
I confirmed that f41 and rawhide are indeed installing python files in the same location.
The problem appears to be in lldb itself.

On Rawhide we have:
$ lldb -P
/usr/lib64/llvm20/lib64/python3.13/site-packages

While on f41:
$ lldb -P
/usr/lib64/python3.13/site-packages

Comment 3 Tulio Magno Quites Machado Filho 2025-04-25 14:10:46 UTC
While this is investigated/fixed, the following might help as a workaround:

    PYTHONPATH=/usr/lib64/python3.13/site-packages lldb

Comment 4 Nikita Popov 2025-07-10 07:53:11 UTC
This has been fixed a while ago as part of (mostly) undoing the prefix changes.

Tested in https://src.fedoraproject.org/tests/llvm/pull-request/55.


Note You need to log in before you can comment on or make changes to this bug.