Based on your description, I could reproduce the issue when I installed nbgv
after I setup the self-hosted pipeline agent.
As suggested in this document, we need to update environment variables after installing new software.
./env.sh
sudo ./svc.sh stop
sudo ./svc.sh start