Also for Mac:
if you do not already have xcode dev tools installed on your system (perhaps you recently upgraded your OS or Xcode), run xcode-select --install
otherwise, a more invasive fix is to set the active directory using the --switch
flag
sudo xcode-select --switch /
from the xcode-select manual:
-s <path>, --switch <path>
Sets the active developer directory to the given path, for example
/Applications/Xcode-beta.app. This command must be run with
superuser permissions (see sudo(8)), and will affect all users on
the system. To set the path without superuser permissions or only
for the current shell session, use the DEVELOPER_DIR environment
variable instead (see ENVIRONMENT).
If you already have Xcode installed, you may have a different problem, in which case, see this post Installing puma 5.6.2 with native extensions Gem::Ext::BuildError: ERROR: Failed to build