前言
CocoaPods安装时报错
?信息如下:
Fetching cocoapods-deintegrate-1.0.5.gem
Fetching ffi-1.15.5.gem
Fetching ethon-0.15.0.gem
Fetching typhoeus-1.4.0.gem
Fetching public_suffix-4.0.6.gem
Fetching fuzzy_match-2.0.4.gem
Fetching concurrent-ruby-1.1.9.gem
Fetching json-2.6.1.gem
Fetching httpclient-2.8.3.gem
Fetching algoliasearch-1.27.5.gem
Fetching addressable-2.8.0.gem
Fetching zeitwerk-2.5.4.gem
Fetching tzinfo-2.0.4.gem
Fetching minitest-5.15.0.gem
Fetching cocoapods-1.11.2.gem
Fetching i18n-1.10.0.gem
Fetching activesupport-6.1.4.6.gem
Fetching cocoapods-core-1.11.2.gem
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0 directory.
解决: 前提我是已经添加了sudo,进行的
sudo gem install -n /usr/local/bin cocoapods
本来是一个权限问题,按照正常操作应该是用sudo或者添加路径应该就能解决了,但是经过多次尝试还是失败,无奈之下重新更新了gem和ruby, 更新:ruby
- 查看当前的版本:
- 列出已知ruby的版本
curl -L https://get.rvm.io | bash -s stable
载入RVM环境
source ~/.rvm/scripts/rvm
检查RVM是否安装成功(查看RVM版本) 继续列出已知的ruby版本 安装ruby
rvm install 2.7
安装rvm时报错:
cunweizhao@xianbingdandan levacp % rvm install 2.7.2
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.15/x86_64/ruby-2.7.2.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Installing requirements for osx.
Updating system - please wait
Failed to update Homebrew, follow instructions at
https://docs.brew.sh/Common-Issues
and make sure `brew update` works before continuing.
Error running 'requirements_osx_brew_update_system ruby-2.7.2',
please read /Users/cunweizhao/.rvm/log/1646018359_ruby-2.7.2/update_system.log
Requirements installation failed with status: 1.
1、更新brew
brew update
提示还是没有权限,我已经添加了sudo,那直接去当前目录添加信息:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0 directory.
貌似不行,然后继续百度查找一下看看 最后 一行添加如下代码
export PATH="/usr/local/opt/ruby/bin:$PATH"
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc 成功
|