Hi guys,
For a long time, my setup for python projects consisted of direnv, nix-shell for python (example below), requirements.txt from pip-tools, VS Code (mostly remote access), and recently, I added Nix Environment Selector for VSC (repository). But with this, I encountered a problem.
As some of python packages require libstdc++.so.6
, I added LD_LIBRARARY_PATH
with it to my shell hook (NixOS Wiki link), but once I’m trying to use it with VSC, all extensions start to crash with errors like: /home/.../.vscode-server/bin/.../node: /lib/x86_64-linux-gnu/libc.so.6: version 'GLIBC_2.34' not found (required by /nix/store/...-gcc-11.2.0-lib/lib/libgcc_s.so.1)
. To solve this, I only need to remove the LD_LIBRARARY_PATH
from my shell hook, but then, I’m back to the problem with python packages (related issue).
Have you encountered something like this? Do you have any idea how to solve it? Or maybe, do you have an entirely different setup for python projects? Thank you!
shell.nix
:
{ sources ? import ./nix/sources.nix }:
with import sources.nixpkgs {};
mkShell {
name = "example-env";
buildInputs = [
python39
nodejs
glibcLocales
];
shellHook = ''
# set SOURCE_DATE_EPOCH so that we can use python wheels
export SOURCE_DATE_EPOCH=315532800
export LD_LIBRARY_PATH=${lib.makeLibraryPath [stdenv.cc.cc]}:$LD_LIBRARY_PATH
'';
preferLocalBuild = true;
}
.envrc
:
use nix
VIRTUAL_ENV="$PWD/venv"
if [ ! -e venv ]
then
python -m venv "${VIRTUAL_ENV}"
fi
export VIRTUAL_ENV
PATH_add "$VIRTUAL_ENV/bin"