There was a problem with the computer recently, and I took it for repair. When I came back, I found that the cocoapods could not be used, which was embarrassing.
Entering sudo gem update --system in the terminal
shows the following error
ERROR: While executing gem … (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory.
See the solution online:
Re-enter the following
sudo gem install -n /usr/local/bin sass
sudo gem install -n /usr/local/bin cocoapods