Error with eventmachine

Solution is here: eventmachine(1.2.7) installation issue on Intel mac with ruby 3.3.0 · Issue #990 · eventmachine/eventmachine · GitHub

My guess is that the C++ compiler on your system is autodetected while installing Ruby and it doesn’t check again, if something about it is not setup right at that point, then subsequent gem installs that require it, like eventmachine, won’t work.

This is why the fix is two steps: uninstall Ruby, get the Apple command-line tools setup properly and working properly (FYI - some folks are having to accept the Apple license), then re-install Ruby.

You can tell that Ruby has found your C++ compiler properly by typing this in a terminal:
ruby -rrbconfig -e 'puts RbConfig::CONFIG["CXX"]'
It should show clang++