-
Notifications
You must be signed in to change notification settings - Fork 330
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
Mixing system packages with python results in shared library errors #1111
Comments
Also running into this when calling system commands from within my Python application. Current band-aid solution is to reset |
@shoskensMagics you mean running |
It's a bit tricky to workaround this. I made #1542, so that we can control the python-wrapper package (and force devenv to use python as-is without wrappers). Apart from the workaround, I also found |
What I've done is to set-up a tasks = {
"venv:libraryPath" = {
exec = ''
# Subprocesses executed from python shouldn't inherit devenv's library path hack
SITE_PACKAGES=($VIRTUAL_ENV/lib/python3*/site-packages)
echo 'import os; os.environ.pop("LD_LIBRARY_PATH", None)' > $SITE_PACKAGES/devenv.pth
'';
after = [ "devenv:python:poetry" ];
before = [ "devenv:enterShell" ];
}; this works, because all |
Injecting `LD_LIBRARY_PATH` to the Python runtime environment is great to bypass the need of having to patch non-nix binaries loaded into that environment, however it breaks down, when Python executes any other program not compiled for the given Nix system, e.g. a shell script via `subprocess`. To work this around, `devenv` will inject a `pth`[^1] file to the virtual environment it creates, which mangles the `LD_LIBRARY_PATH` variable, undoing any changes to it made by `devenv` but preserving changes from other sources. Fixes cachix#1111 [^1]: https://docs.python.org/3/library/site.html
Describe the bug
When using system packages from within a python application
symbol lookup error
may happen.This happens when the system package (like
git
) is linked against a different version oflibc
compared to the python version (from devenv) is linked against.A specific case where this happens more often occurs when using a remote git repository as a requirement for your devenv-based python project. devenv calls
pip install -r requirements.txt
, which will rungit
.git
is usually not defined inside devenv, thus the requiredlibc
is likely to be different from what is used in devenv. Thepython
wrapper within devenv runs python withLD_LIBRARY_PATH=$DEVENV_PROFILE/lib
, which will force ld to use libraries within$DEVENV_PROFILE/lib
. Thelibc
that resides in$DEVENV_PROFILE/lib
is a different version than whatgit
assumes to be ld-ed against.This results in errors like the following:
Potential solutions
git
topackages
in devenv will resolve the problem with git, but on my system I got the next binary that resulted in the a similar error (gh
). Adding all personal tools is one way to get over this problem.LD_LIBRARY_PATH
upon calling other binaries from within the wrapped devenv python.patchelf
/autopatchelf
. In addition,LD_LIBRARY_PATH
should not be used so thatld
won't be forced to use different libraries. See PR python: add patchelf option #840 as a poc.To reproduce
Follow the instructions from the readme:
https://gist.github.com/bobvanderlinden/f31299079b67ddcc1b2c6029cf6569f6
Version
The text was updated successfully, but these errors were encountered: