Mac m2 Ventura(13.4)安装Cocoapods

1.执行命令

sudo gem install cocoapods

 报错:You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory

非常不推荐 sudo 安装!!!

2.安装新的homebrew(参考 官网 https://github.com/homebrew/install#uninstall-homebrew)

首先卸载:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"

然后安装新的

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

 注意科学上网

或者配置 hosts 185.199.108.133 raw.githubusercontent.com

3.使用ruby 版本管理安装 新的ruby

参考:The fastest and easiest way to install Ruby on a Mac in 2023

brew install chruby ruby-install
ruby-install ruby 3.2.2

4.配置环境

echo "source $(brew --prefix)/opt/chruby/share/chruby/chruby.sh" >> ~/.zshrc
echo "source $(brew --prefix)/opt/chruby/share/chruby/auto.sh" >> ~/.zshrc
echo "chruby ruby-3.2.2" >> ~/.zshrc

 5.验证

source ~/.zshrc 

ruby -v

6.不需要 sudo 

gem install cocoapods

你可能感兴趣的:(macos,cocoapods,xcode)