ruby 无法在Mac上安装json gem

eh57zj3b  于 2022-11-04  发布在  Ruby
关注(0)|答案(1)|浏览(239)

我无法在我的M1 MacBook上安装json gem。这是我正在运行的命令。

sudo gem install json -v '2.6.2'

这就是我遇到的错误。我猜是因为它正在使用Xcode 14.1 Beta 3,但我不知道如何让它使用不同版本的Xcode,或者这是否是问题。

Building native extensions. This could take a while...
ERROR:  Error installing json:
    ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.6.0/gems/json-2.6.2/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 ./siteconf20221018-37799-1wcwkww.rb extconf.rb
creating Makefile

current directory: /Library/Ruby/Gems/2.6.0/gems/json-2.6.2/ext/json/ext/generator
make "DESTDIR=" clean

current directory: /Library/Ruby/Gems/2.6.0/gems/json-2.6.2/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-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby.h:33:
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.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"

         ^~~~~~~~~~~~~~~
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: note: did not find header 'config.h' in framework 'ruby' (loaded from '/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks')
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.6.2 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-21/2.6.0/json-2.6.2/gem_make.out
ozxc1zmp

ozxc1zmp1#

此问题已在此处报告,https://github.com/rubygems/bundler/issues/4462。您可以尝试bundle update && bundle install吗?bundle update将安装您的所有依赖项,但如果您不想更新所有依赖项,请仅尝试bundle update json

相关问题