This worked for me.
Also there was an error reinstalling Ruby when running sudo gem update -system
ERROR: While executing gem ... (Errno::EPERM) Operation not permitted @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/gem
Then I tried to run the same command again (sudo gem update - system) and got the latest version already installed . Done.
Instead of starting
sudo gem install cocoapods
to try
sudo gem install -n /usr/local/bin cocoapods
Which finished working for me! Did not clear previous cocoapods with a bash script, as you did in step 1, but should not make any difference as you reinstall.
source share