Update: Recently, after updating the Mac system to macOS High Sierra, the following prompt appears in pod install:
-bash: /usr/local/bin/pod: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby: bad interpreter: No such file or directory
After inquiries, it was found that the problem could be solved like this
sudo gem update --system sudo gem install -n /usr/local/bin cocoapods