Or at least, you must accept the license somewhere. I have found that launching Xcode and accepting the license through the GUI also works. My personal routine is to always start Xcode once after install/update to make sure things like licenses and command-line tool installation get taken care of.

I had the same problem with other 3rd-party programs that failed in mysterious ways when the Xcode license hadn’t been accepted.