Using following commands, it worked for me.
sudo gem uninstall cocoapodssudo gem install -n /usr/local/bin cocoapodscocoapods pod install
If you encounter this error on step 2:
ERROR: While executing gem ... (Gem::CommandLineError) Please specify at least one gem name (e.g. gem build GEMNAME)
Then try this as step 2 instead (step 3 is not needed):
gem install -n /usr/local/bin cocoapods