Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

liblldb cannot find python installation #329246

Closed
danobi opened this issue Jul 22, 2024 · 3 comments
Closed

liblldb cannot find python installation #329246

danobi opened this issue Jul 22, 2024 · 3 comments
Labels
0.kind: bug Something is broken 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related

Comments

@danobi
Copy link

danobi commented Jul 22, 2024

Describe the bug

When bpftrace is linked against liblldb and tries to initialize it, we get the error:

Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'python3'
  isolated = 0
  environment = 1
  user site = 1
  safe_path = 0
  import site = 1
  is in build tree = 0
  stdlib dir = '/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11'
  sys._base_executable = '/usr/bin/python3'
  sys.base_prefix = '/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9'
  sys.base_exec_prefix = '/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9'
  sys.platlibdir = 'lib'
  sys.executable = '/usr/bin/python3'
  sys.prefix = '/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9'
  sys.exec_prefix = '/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9'
  sys.path = [
    '/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python311.zip',
    '/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11',
    '/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
LookupError: no codec search functions registered: can't find encoding

Current thread 0x000072dd680c07c0 (most recent call first):
  <no Python frame>

Steps To Reproduce

Steps to reproduce the behavior:

  1. clone bpftrace repo (https://github.com/bpftrace/bpftrace)
  2. nix build .#appimage
  3. echo "int main() {return 0;}" | gcc -g -x c -
  4. sudo ./result -e 'uprobe:./a.out:main { @ = count(); }'

Expected behavior

Not to get this error

Additional context

When I set PYTHONPATH to my host stdlib location it seems to work better (but still has odd errors):

$ sudo PYTHONPATH=/usr/lib/python3.12 ./result -e 'uprobe:./a.out:main { @ = count(); }'
Could not find platform independent libraries <prefix>
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'lldb.embedded_interpreter'
Attaching 1 probe...
^C

@: 0

Maybe it's an issue with PYTHONPATH? I see some magic is being done for the lldb executable here:

wrapProgram $out/bin/lldb --prefix PYTHONPATH : $lib/${python3.sitePackages}/

Alternatively would it make sense to provide a build option to not build with language support?

Notify maintainers

@dtzWill
@Ericson2314
@lovek323
@qyliss
@RossComputerGuy
@rrbutani
@sternenseemann

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.8.7-arch1-2, Arch Linux, noversion, rolling`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.17.0`
 - nixpkgs: `/home/dxu/.nix-defexpr/channels/nixpkgs`

Add a 👍 reaction to issues you find important.

@danobi danobi added the 0.kind: bug Something is broken label Jul 22, 2024
@danobi
Copy link
Author

danobi commented Jul 22, 2024

Nevermind, turns out we're stripping python files out of the appimage. Sorry for the noise

@danobi danobi closed this as completed Jul 22, 2024
@rrbutani rrbutani added the 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related label Jul 22, 2024
@baiwfg2
Copy link

baiwfg2 commented Dec 2, 2024

@danobi Hi, I met with this problem today. What does that mean ? How to solve it ?

@danobi
Copy link
Author

danobi commented Dec 2, 2024

Hi @baiwfg2 , this was fixed on bpftrace side in bpftrace/bpftrace@0e71958 . Please check that your build contains that commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related
Projects
None yet
Development

No branches or pull requests

3 participants