YAML|YAML safe loading is not available

YAML safe loading is not available. Please upgrade psych to a version that supports safe loading (>= 2.0).ERROR:SSL verification error at depth 1: unable to get local issuer certificate (20)ERROR:You must add /O=Digital Signature Trust Co./CN=DST Root CA X3 to your local trusted storeERROR:While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

此问题出现场景毕竟其实毕竟多. 基本上执行gem install xxx 都可能发生.
网上搜索大部分是
gem install cocoapods gem install xxxx

然后修复方法大部分都是
gem install -n /usr/local/bin cocoapods gem install -n /usr/local/bin xxx

之前偶尔换系统之类的按照cocoapods我也使用过此方法, 但是总想一探究竟.
解决方法
更新 ruby
  1. 如果没有安装那就先安装
    curl -sSL https://get.rvm.io | bash -s stable

  2. 看看目前能更新的最高版本是哪个?
    rvm list known

  3. 查找类似 [ruby-]2.4[.1] 的地方, 查看最高支持的版本.
    rvm install ruby 2.4// 发文章最新版为2.4

【YAML|YAML safe loading is not available】静静等待几分钟, 以后任意使用
gem install xxxx

    推荐阅读