don‘t have write permissions for the /System/Library/Frameworks/Ruby.framework

这篇具有很好参考价值的文章主要介绍了don‘t have write permissions for the /System/Library/Frameworks/Ruby.framework。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

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)")。
don‘t have write permissions for the /System/Library/Frameworks/Ruby.framework,工具,实用小技术,工程编译,ruby,ios
2.通过Hombrew安装ruby

brew install ruby

don‘t have write permissions for the /System/Library/Frameworks/Ruby.framework,工具,实用小技术,工程编译,ruby,ios
安装到最后有一段命令提示语(echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc),安装成功执行该命令修改环境变量。
don‘t have write permissions for the /System/Library/Frameworks/Ruby.framework,工具,实用小技术,工程编译,ruby,ios
查看当前的ruby,最后执行更新cocoapods(sudo gem install -n /usr/local/bin cocoapods --pre)
don‘t have write permissions for the /System/Library/Frameworks/Ruby.framework,工具,实用小技术,工程编译,ruby,ios
don‘t have write permissions for the /System/Library/Frameworks/Ruby.framework,工具,实用小技术,工程编译,ruby,ios文章来源地址https://www.toymoban.com/news/detail-610257.html

到了这里,关于don‘t have write permissions for the /System/Library/Frameworks/Ruby.framework的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包