Gem:Ext::BuildError: ERROR: Failed to build gem native extension on Mac

Gem:Ext::BuildError: ERROR: Failed to build gem native extension on Mac

我是一名初级程序员。我不知道这个问题。

首先,我想在 Jekyll 中使用这个主题“https://github.com/cotes2020/jekyll-theme-chirpy” 所以,我根据解释在这个网站“https://jekyllrb.com/docs/installation/macos/”下载了Gem、Ruby等。

但是,Ruby有问题...

 
bagjun-yeong@bagjun-yeong-ui-MacBookPro UCDAyoung.github.io % bundle install
Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
Using public_suffix 4.0.6
Using bundler 2.2.17
Using mercenary 0.4.0
Using colorator 1.1.0
Using eventmachine 1.2.7
Using http_parser.rb 0.6.0
Using ffi 1.15.1
Using forwardable-extended 2.6.0
Using concurrent-ruby 1.1.8
Following files may not be writable, so sudo is needed:
  /Library/Ruby/Gems/2.6.0
  /Library/Ruby/Gems/2.6.0/build_info
  /Library/Ruby/Gems/2.6.0/cache
  /Library/Ruby/Gems/2.6.0/doc
  /Library/Ruby/Gems/2.6.0/extensions
  /Library/Ruby/Gems/2.6.0/gems
  /Library/Ruby/Gems/2.6.0/plugins
  /Library/Ruby/Gems/2.6.0/specifications
Using racc 1.5.2
Using rainbow 3.0.0
Using liquid 4.0.3
Using rouge 3.26.0
Using safe_yaml 1.0.5
Using unicode-display_width 1.7.0
Using jekyll-paginate 1.1.0
Using nokogiri 1.11.5 (arm64-darwin)
Using ethon 0.14.0
Using i18n 1.8.10
Using sassc 2.4.0
Using rb-inotify 0.10.1
Using pathutil 0.16.2
Using terminal-table 2.0.0
Using rb-fsevent 0.11.0
Using typhoeus 1.4.0
Using jekyll-sass-converter 2.1.0
Using listen 3.5.1
Using addressable 2.7.0
Using jekyll-watch 2.2.1
Using yell 2.2.2
Using rexml 3.2.5
Using parallel 1.20.1
Using em-websocket 0.5.2
Using nokogiri 1.11.5 (x86_64-darwin)
Using kramdown 2.3.1
Using kramdown-parser-gfm 1.1.0
Using jekyll 4.2.0
Using jekyll-archives 2.2.1
Using jekyll-redirect-from 0.16.0
Using jekyll-seo-tag 2.7.1
Using jekyll-sitemap 1.4.0
Using jekyll-theme-chirpy 4.0.1 from source at `.`
Fetching nokogumbo 2.0.5


Your user account isn't allowed to install to the system RubyGems.
  You can cancel this installation and run:

      bundle config set --local path 'vendor/bundle'
      bundle install

  to install the gems into ./vendor/bundle/, or you can enter your password
  and install the bundled gems to RubyGems using sudo.

  Password: 


Your user account isn't allowed to install to the system RubyGems.
  You can cancel this installation and run:

      bundle config set --local path 'vendor/bundle'
      bundle install

  to install the gems into ./vendor/bundle/, or you can enter your password
  and install the bundled gems to RubyGems using sudo.

  Password: 

The reason why I thought it was overlapped is Terminal asked me to enter my passwords 2 times to install the gem.

Installing nokogumbo 2.0.5 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/var/folders/h5/pv309pys7cd7_k058rl0wgx40000gn/T/bundler20210526-4419-9z2i9nnokogumbo-2.0.5/gems/nokogumbo-2.0.5/ext/nokogumbo
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf20210526-4419-z9tg1b.rb
extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME)
/Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:160:in `require': cannot load such file -- nokogiri/nokogiri
(LoadError)
    from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:160:in `rescue in require'
    from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:149:in `require'
    from /Library/Ruby/Gems/2.6.0/gems/nokogiri-1.11.5-arm64-darwin/lib/nokogiri/extension.rb:25:in `rescue in <top (required)>'
    from /Library/Ruby/Gems/2.6.0/gems/nokogiri-1.11.5-arm64-darwin/lib/nokogiri/extension.rb:4:in `<top (required)>'
    from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require'
    from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require'
    from /Library/Ruby/Gems/2.6.0/gems/nokogiri-1.11.5-arm64-darwin/lib/nokogiri.rb:11:in `<top (required)>'
    from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:160:in `require'
    from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:160:in `rescue in require'
    from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:149:in `require'
    from extconf.rb:4:in `<main>'
/Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require': cannot load such file -- nokogiri/nokogiri (LoadError)
    from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require'
    from /Library/Ruby/Gems/2.6.0/gems/nokogiri-1.11.5-arm64-darwin/lib/nokogiri/extension.rb:25:in `rescue in <top (required)>'
    from /Library/Ruby/Gems/2.6.0/gems/nokogiri-1.11.5-arm64-darwin/lib/nokogiri/extension.rb:4:in `<top (required)>'
    from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require'
    from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require'
    from /Library/Ruby/Gems/2.6.0/gems/nokogiri-1.11.5-arm64-darwin/lib/nokogiri.rb:11:in `<top (required)>'
    from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:160:in `require'
    from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:160:in `rescue in require'
    from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:149:in `require'
    from extconf.rb:4:in `<main>'
/Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require':
dlopen(/Library/Ruby/Gems/2.6.0/gems/nokogiri-1.11.5-arm64-darwin/lib/nokogiri/2.6/nokogiri.bundle, 0x0009): could not use
'/Library/Ruby/Gems/2.6.0/gems/nokogiri-1.11.5-arm64-darwin/lib/nokogiri/2.6/nokogiri.bundle' because it is not a compatible arch -
/Library/Ruby/Gems/2.6.0/gems/nokogiri-1.11.5-arm64-darwin/lib/nokogiri/2.6/nokogiri.bundle (LoadError)
    from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require'
    from /Library/Ruby/Gems/2.6.0/gems/nokogiri-1.11.5-arm64-darwin/lib/nokogiri/extension.rb:6:in `<top (required)>'
    from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require'
    from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require'
    from /Library/Ruby/Gems/2.6.0/gems/nokogiri-1.11.5-arm64-darwin/lib/nokogiri.rb:11:in `<top (required)>'
    from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:160:in `require'
    from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:160:in `rescue in require'
    from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:149:in `require'
    from extconf.rb:4:in `<main>'
/Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require': cannot load such file -- nokogiri (LoadError)
    from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_require.rb:85:in `require'
    from extconf.rb:4:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in
/var/folders/h5/pv309pys7cd7_k058rl0wgx40000gn/T/bundler20210526-4419-9z2i9nnokogumbo-2.0.5/gems/nokogumbo-2.0.5 for inspection.
Results logged to
/var/folders/h5/pv309pys7cd7_k058rl0wgx40000gn/T/bundler20210526-4419-9z2i9nnokogumbo-2.0.5/extensions/universal-darwin-20/2.6.0/nokogumbo-2.0.5/gem_make.out

An error occurred while installing nokogumbo (2.0.5), and Bundler cannot continue.
Make sure that `gem install nokogumbo -v '2.0.5' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  html-proofer was resolved to 3.19.1, which depends on
    nokogumbo

also, I did gem install nokogumbo -v '2.0.5' --source 'https://rubygems.org/' but, it didn't work, too.

请帮我解决这个问题problem.Thank你太好了

尝试在安装 shopify-cli 之前安装这些依赖项

sudo apt-get install build-essential

sudo apt-get install bison openssl curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev autoconf libc6-dev ncurses-dev automake libtool

您可以在终端中通过运行 xcode-select --install安装依赖项。

这是对类似问题的详细回答 How to install Xcode Command Line Tools