don’t have write permissions for the /System/Library/Frameworks/Ruby.framework
sudo gem install sigh或sudo gem install -n /usr/local/bin cocoapods --pre出现:
apple@CQIMAC-L1A9Q05R ~ % sudo gem update --system
Password:
Updating rubygems-update
Fetching rubygems-update-3.4.14.gem
Successfully installed rubygems-update-3.4.14
Parsing documentation for rubygems-update-3.4.14
Installing ri documentation for rubygems-update-3.4.14
Installing darkfish documentation for rubygems-update-3.4.14
Done installing documentation for rubygems-update after 189 seconds
Parsing documentation for rubygems-update-3.4.14
Done installing documentation for rubygems-update after 0 seconds
Installing RubyGems 3.4.14
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/gem
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1387:in `initialize'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1387:in `open'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1387:in `block in copy_file'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1386:in `open'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1386:in `copy_file'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:492:in `copy_file'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:860:in `block in install'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1558:in `block in fu_each_src_dest'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1574:in `fu_each_src_dest0'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1556:in `fu_each_src_dest'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:856:in `install'
/Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.14/lib/rubygems/commands/setup_command.rb:267:in `block (2 levels) in install_executables'
/Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.14/lib/rubygems/commands/setup_command.rb:251:in `chdir'
/Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.14/lib/rubygems/commands/setup_command.rb:251:in `block in install_executables'
/Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.14/lib/rubygems/commands/setup_command.rb:248:in `each'
/Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.14/lib/rubygems/commands/setup_command.rb:248:in `install_executables'
/Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.14/lib/rubygems/commands/setup_command.rb:165:in `execute'
/Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.14/lib/rubygems/command.rb:327:in `invoke_with_build_args'
/Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.14/lib/rubygems/command_manager.rb:252:in `invoke_command'
/Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.14/lib/rubygems/command_manager.rb:192:in `process_args'
/Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.14/lib/rubygems/command_manager.rb:150:in `run'
/Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.14/lib/rubygems/gem_runner.rb:51:in `run'
setup.rb:33:in `<main>'
执行:pod --version
apple@CQIMAC-L1A9Q05R ~ % pod --version
/Library/Ruby/Site/2.6.0/rubygems.rb:263:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) with executable pod (Gem::GemNotFoundException)
from /Library/Ruby/Site/2.6.0/rubygems.rb:282:in `activate_bin_path'
from /usr/local/bin/pod:23:in `<main>'
解决办法:
1、将终端从从 bash 切换到 zsh(之前不知道啥时候设置成了bash,后来查询资料mac终端一般都是默认使用的是zsh)
如何切换参考:https://www.jianshu.com/p/261207b75568
2、执行 sudo 以及 -n /usr/local/bin 后再执行sudo gem install sigh安装依然报没权限
3、查阅相关资料说是mac自带的ruby种新版本系统不允许做授权之类操作,然后执行
ruby -v
查看到系统自带的ruby2.6版本
apple@CQIMAC-L1A9Q05R ~ % ruby -v
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.x86_64-darwin22]
接着执行
which ruby
查看到2.6版本的ruby目录为
apple@CQIMAC-L1A9Q05R ~ % which -a ruby
/usr/bin/ruby
以上问题通过修改系统文件夹权限无法解决,只能使用下面的方案:安装Hombrew,通过它安装ruby,然后修改环境变量让它成为当前的ruby。
1.继续下载Hombrew(国内镜像地址安装命令:"$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
)。
2.通过Hombrew安装ruby文章来源:https://www.toymoban.com/news/detail-610257.html
brew install ruby
安装到最后有一段命令提示语(echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc
),安装成功执行该命令修改环境变量。
查看当前的ruby,最后执行更新cocoapods(sudo gem install -n /usr/local/bin cocoapods --pre
)
文章来源地址https://www.toymoban.com/news/detail-610257.html
到了这里,关于don‘t have write permissions for the /System/Library/Frameworks/Ruby.framework的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!