This is only one of the reasons why this may happen – Xcode Command Line Tools (CLT) are not installed. This may happen after you upgrade you macOS version.
To fix, run this on the command line:
xcode-select --install
this should trigger a popup with the invitation to install Xcode CLT.