【问题标题】:ERROR: Failed to build gem native extension. and You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory错误:无法构建 gem 原生扩展。并且您没有 /Library/Ruby/Gems/2.6.0 目录的写入权限
【发布时间】:2021-07-16 06:12:42
【问题描述】:

我已经从应用商店安装了 Xcode 以获得更新版本。现在我正在安装 cocoapods。对于安装,我使用 sudo gem install cocoapods 它显示此错误

Building native extensions. This could take a while...
    ERROR:  Error installing cocoapods:
        ERROR: Failed to build gem native extension.
    
        current directory: /Library/Ruby/Gems/2.6.0/gems/json-2.5.1/ext/json/ext/generator
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20210422-1825-1sq5o2c.rb extconf.rb
    creating Makefile
    
    current directory: /Library/Ruby/Gems/2.6.0/gems/json-2.5.1/ext/json/ext/generator
    make "DESTDIR=" clean
    
    current directory: /Library/Ruby/Gems/2.6.0/gems/json-2.5.1/ext/json/ext/generator
    make "DESTDIR="
    compiling generator.c
    In file included from generator.c:1:
    In file included from ./../fbuffer/fbuffer.h:5:
    In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby.h:33:
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found
    #include "ruby/config.h"
             ^~~~~~~~~~~~~~~
    1 error generated.
    make: *** [generator.o] Error 1
    
    make failed, exit code 2
    
    Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/json-2.5.1 for inspection.
    Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/json-2.5.1/gem_make.out.

当我使用 gem install cocoapods 然后它会显示错误

ERROR:  While executing gem ... 
(Gem::FilePermissionError)
        You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory how to fix 

我已经尝试了这么多教程。

【问题讨论】:

    标签: ios ruby xcode rubygems cocoapods


    【解决方案1】:

    不要使用 System ruby​​(/Library/Ruby 中的那个),因为 macOS 会限制对它的访问。

    尝试使用 Rbenv 安装 Ruby,遵循以下指南:https://gorails.com/setup/osx/11.0-big-sur(遵循 安装 Ruby 部分)。

    安装后,退出终端(Command + q),再次打开并尝试再次安装cocoapods,希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 2021-01-31
      • 2019-01-10
      • 2018-12-10
      • 2014-11-01
      • 2015-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多