Installing cocoapods on macOS Mojave
It looks like CocoaPods 1.9.0, the latest version as of this writing, depends on a newer version of Ruby than 2.3.7. But macOS Mojave only includes Ruby 2.3.7, so you have a few different options.


Upgrade to macOS Catalina and get Ruby 2.6.3
Use Ruby Version Manager to install a newer version of Ruby
Install an older version of CocoaPods
sudo gem install cocoapods -v 1.8.4


Sources

Other people have trouble with CocoaPods 1.9.0 on Mojave. 1 2 3 4 5

Some people got it working by upgrading to Ruby 2.6 or newer. 1 2