I want to share with you how I manage my toolset as iOS developer. iOS development is based on 3rd party tools (like cocapods, fastlane) and those tools are, mostly, writen in ruby. So we need to take care of ruby environment if we want to our work be no problematic and efficiant.
First of all - default macOS ruby is shit. Just accept that. We need to replace it and the best way to do it is a tool like rbenv. Rbenv is not only tool for this job, but it's good to start.
Second - brew is an excellent tool but not everything need to be installed via it. I know, it's tempting to use only one package manager for everything but life is life and it's not perfect.
So if you have issues like this: