The above did not work for me. Instead, I added Xcode and Terminal to the Developer Tools in the settings:
System Settings → Privacy & Security → Developer Tools.
Additionally, I installed Rosetta with the following command:
softwareupdate --install-rosetta --agree-to-license