ios 在macOS上安装cocoapod时您没有写入权限

6rqinv9w  于 2023-01-03  发布在  iOS
关注(0)|答案(1)|浏览(247)

在MacOS(M1芯片)上安装cocopods时出错,我运行了sudo gem install cocoapods命令,得到了以下错误。

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.
    /Library/Ruby/Site/2.6.0/rubygems/installer.rb:712:in `verify_gem_home'
    /Library/Ruby/Site/2.6.0/rubygems/installer.rb:902:in `pre_install_checks'
    /Library/Ruby/Site/2.6.0/rubygems/installer.rb:302:in `install'
    /Library/Ruby/Site/2.6.0/rubygems/resolver/specification.rb:104:in `install'
    /Library/Ruby/Site/2.6.0/rubygems/request_set.rb:194:in `block in install'
    /Library/Ruby/Site/2.6.0/rubygems/request_set.rb:182:in `each'
    /Library/Ruby/Site/2.6.0/rubygems/request_set.rb:182:in `install'
    /Library/Ruby/Site/2.6.0/rubygems/commands/install_command.rb:214:in `install_gem'
    /Library/Ruby/Site/2.6.0/rubygems/commands/install_command.rb:230:in `block in install_gems'
    /Library/Ruby/Site/2.6.0/rubygems/commands/install_command.rb:223:in `each'
    /Library/Ruby/Site/2.6.0/rubygems/commands/install_command.rb:223:in `install_gems'
    /Library/Ruby/Site/2.6.0/rubygems/commands/install_command.rb:169:in `execute'
    /Library/Ruby/Site/2.6.0/rubygems/command.rb:323:in `invoke_with_build_args'
    /Library/Ruby/Site/2.6.0/rubygems/command_manager.rb:185:in `process_args'
    /Library/Ruby/Site/2.6.0/rubygems/command_manager.rb:149:in `run'
    /Library/Ruby/Site/2.6.0/rubygems/gem_runner.rb:51:in `run'
    /usr/bin/gem:21:in `<main>'

期望值:pod命令用于安装和设置是正确。

a9wyjsp7

a9wyjsp71#

经过多次搜索苹果开发论坛,我发现一个解决方案是有帮助的,所以我坚持在这里的代码。
步骤1:安装自制程序

$ curl -fsSL -o install.sh https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
$ /bin/bash install.sh

步骤2:brew install chruby ruby-install
步骤3:brew install cocoapods
步骤4:brew upgrade cocoapods
现在您可以在iOS项目上使用pod install

相关问题