you need to update/downgrade ruby please follow these instructions as i had the same issue and fixed by this one
https://dev.to/luizgadao/easy-way-to-change-ruby-version-in-mac-m1-m2-and-m3-16hl