微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Gem:Ext::BuildError: 错误:无法在 Mac 上构建 gem 本机扩展

如何解决Gem:Ext::BuildError: 错误:无法在 Mac 上构建 gem 本机扩展

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

首先,我想在 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: 

我认为它重叠的原因是终端要求我输入密码两次以安装 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

另外,我做了 gem install nokogumbo -v '2.0.5' --source 'https://rubygems.org/' 但是,它也不起作用。

请帮我解决这个问题。非常感谢。

解决方法

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

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

,

在安装 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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。