After lots of trial and error, I finally got ruby 2.7.6 installed on my early mac m1 (macOS 12.6).
There are many blog posts out there suggesting different flags, ignoring warnings etc. But in the end, this is what worked for me.
DO NOT use the brew / ibrew setup, where ibrew is aliased to arch -x86_64 /usr/local/bin/brew
.
It will mess up your system with conflicting packages and paths.
Use a terminal without Rosetta 2.