Skip to main content

macOS 13.0 Cocoapods installation (you don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory)

❓You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory

❓Cause of the problem: There is a folder permission problem when installing Cocoapods🔧Try to solve it: try to solve it by sudo with super administrator rights (personal test does not work❌)

🔧Try to solve: Try to solve the problem by restarting and turning off SIP (personal test does not work❌)

Conclusion: After consulting the relevant information, I found that there is currently no simple direct solution for macOS 13.0 (there is another very troublesome direct solution), but it can be installed through Brew bypasses the permission problem

☑️Solution:

🔧Install brew by installing the package manager Homebrew (also called brew), then install Cocoapods through brew, bypass the permission problem to install Homebrew, it is recommended to use Tencent source (if this does not work, change to another source , sometimes this line, sometimes that line), use the regular installation script, run from the command line

Apple computer regular installation script (recommended to complete the installation in a few minutes):
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

Apple Computer Rapid Installation Script (Lite Version Completed in seconds):
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.

Diagnose the problem. After the installation is complete, check if there are any problems. Run the command line and follow the prompts to solve the problem. XcodeYou can ignore the updated version for the time being.

brew doctor

🔧Install ruby ​​(if not required, you can skip to the step of installing Cocopods)

brew install ruby

ruby whether the installation is successful and query the relevant installation directory

/usr/bin/ruby for the system directory

Which ruby
Output result:/usr/bin/ruby
Ruby - v
Output result: Ruby 2.6.10p210 (2022-04-12 revision 67958) [universal. arm64e darwin22]

Configure the relevant environment Pathso that Brewinstallation Rubycalls take precedence over system callsRuby

echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
If it is not intela chip or the above statement fails to execute, you can choose the following method

Or go to the file ~/.zshrc, open the editor and add relevant statements (select according to the chip type)

intelchip add this

if [ -d "/opt/homebrew/opt/ruby/bin" ]; then
export PATH=/opt/homebrew/opt/ruby/bin:$PATH
export PATH=`gem environment gemdir`/bin:$PATH
fi

Install Cocopods

by brew installing Cocoapods

brew install cocoapods

Check Cocoapods whether the installation is successful. Run the command line. If the version number is displayed, the installation is successful😄!

If there is this prompt: You may want to remove it: rm '/usr/local/bin/pod'

Here's what I do on my Mojave machine:
brew reinstall cocoapods
brew link --overwrite cocoapods, override the default settings pod
$ brew reinstall cocoapods
==> Downloading https://homebrew.bintray.com/bottles/cocoapods-1.9.3.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/07/074e5b53b7a054c132582183dcf47546ddd028a7beb9fcdc653fe4a43225bcf3?__gda__=exp=1593894546~hmac=8b
######################################################################## 100.0%
==> Reinstalling cocoapods
==> Pouring cocoapods-1.9.3.mojave.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/pod
Target /usr/local/bin/pod
already exists. You may want to remove it:
rm '/usr/local/bin/pod'

To force the link and overwrite all conflicting files:
brew link --overwrite cocoapods

To list all files that would be deleted:
brew link --overwrite --dry-run cocoapods

Possible conflicting files are:
/usr/local/bin/pod
/usr/local/bin/xcodeproj
==> Summary
? /usr/local/Cellar/cocoapods/1.9.3: 12,705 files, 28.0MB

$ brew link --overwrite cocoapods
Linking /usr/local/Cellar/cocoapods/1.9.3... 2 symlinks created

ls checks installation and version testing

$ ls -al $(which pod)
lrwxr-xr-x 1 rchen staff 33 Jul 4 16:17 /usr/local/bin/pod -> ../Cellar/cocoapods/1.9.3/bin/pod

$ pod --version
1.9.3

Success~