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)")。

2.通过Hombrew安装ruby

brew install ruby

安装到最后有一段命令提示语(echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc),安装成功执行该命令修改环境变量。

查看当前的ruby,最后执行更新cocoapods(sudo gem install -n /usr/local/bin cocoapods --pre)

22c367fdbeaa45e6a36541f7a42ba933.jpg

目录
相关文章
|
编译器 C++ 计算机视觉
error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools“
error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools“
858 0
|
Java Android开发
Failed to load JavaHL Library.These are the errors that were encountered:no msvcp100 in java.library
Failed to load JavaHL Library.These are the errors that were encountered:no msvcp100 in java.library
codeblocks中出现#error This file requires compiler and library support for the错误时的解决方案
codeblocks中出现#error This file requires compiler and library support for the错误时的解决方案
728 0
codeblocks中出现#error This file requires compiler and library support for the错误时的解决方案
|
C++
error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools“:
error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools“:
343 0
error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools“:
|
Java
编译OpenJDK:invalid configuration Files: machine Files not recognized
编译OpenJDK:invalid configuration Files: machine Files not recognized
111 0
|
机器人 Python 数据格式
Robot Framework's built-in tool:libdoc
Libdoc是Robot框架的内置工具之一,用于生成HTML和XML格式的测试库和资源文件的关键字文档,使用起来我感觉非常的灵活方便。 General Usage 语法使用 python -m robot.
1384 0
|
新零售 测试技术 Python
Robot Framework - Variable file
RF导入变量文件 在Setting中导入 Setting中导入变量文件时,和导入外部资源文件类似。变量文件的路径可以包含参数,如果一个变量文件接受参数,那么它们也可以是变量。
1369 0
|
分布式计算 Java Hadoop
17/11/24 05:08:44 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
2017-11-24 21:20:25 1:什么叫失望,什么叫绝望。总之是一脸懵逼的继续...... 之前部署的hadoop都是hadoop-2.4.1.tar.gz,这几天换成了hadoop-2.6.4.tar.gz,部署老生常谈,启动就不一样了,本来吧,也就是warn,不是error,启动hdfs和yarn,节点都可以正常启动,但是对于我这种强迫症,能容忍下面这一大推错误吗?当你看到这篇的时候,显然是不能,虽然网上已经有很多了,但是貌似好多还是不好使。
2721 0
|
Java Go Windows
DEPLOYING NATIVE UWP (UNIVERSAL WINDOWS PLATFORM) APPS FOR JAVA DEVELOPERS & PUBLISHING THEM TO THE MICROSOFT STORE
原文: DEPLOYING NATIVE UWP (UNIVERSAL WINDOWS PLATFORM) APPS FOR JAVA DEVELOPERS & PUBLISHING THEM TO THE MICROSOFT STORE UWP Apps may distributed in 2 different ways: In the Windows App Store.
1448 0