I had an older and new Ubuntu installed (22.04 and 24.04) and the 22.04 was the default when opening VS Code. The issue turned out to be in the configuration of WSL as described here: How do I open a wsl workspace in VS Code for a different distro?