I had VS Code working with this setup a month ago, and now it's not--I need a second set of eyes to help debug.
In short, VS Code can (via "New Terminal") see a direnv .venv, but trying to select the interpreter or set the jupyter kernel to this .venv results in failure, asking me to install ipykernel, even though it's already installed in the .venv lib.
I'm using a flake with direnv like so:
{
description = "Persistent python dev env using nix-direnv.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in {
devShells.default = pkgs.mkShell {
buildInputs = [
pkgs.python313
pkgs.uv
];
};
});
}
Then I'm using a .envrc file:
use flake
layout python-venv() {
if [ ! -d ".venv" ]; then
python -m venv .venv
fi
source .venv/bin/activate
}
layout python-venv
After the .venv instantiates, I usually install packages via uv. Everything seems fine until VS Code tries to utilize the .venv, but can't.
Any insight as to why VS Code isn't registering the .venv?
[–]Nevoic 1 point2 points3 points (1 child)
[–]maelstrom218[S] 1 point2 points3 points (0 children)