Cannot install any version of ruby on Mojave - internal ranlib command failed

For anyone else who steps on the same landmine, for me it was that there was an incompatible copy of ranlib from homebrew via the cctools package. To fix it, I just uninstalled it:

brew uninstall cctools


For those who find this and aren't helped by the above solution...

I ran into this issue as well. In my case it was due to MacPorts being outdated after I upgraded to (MacOS) Mojave.

I followed the steps listed on MacPorts' migration guide here: https://trac.macports.org/wiki/Migration

Closed and reopened Terminal (just b/c)

ran rvm install ruby and got Install of ruby-2.6.0 - #complete, hooray!