首页 > 解决方案 > 安装 Jekyll 时出错:无法构建原生扩展 | macOS 大苏尔

问题描述

也许有人可以帮助我。我按照https://jekyllrb.com/docs/installation/macos/上的说明 通过自制软件安装了 Ruby 3.0.1 并设置了所有路径。

ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-darwin20]


- EXECUTABLE DIRECTORY: /usr/local/lib/ruby/gems/3.0.0/bin

- GEM PATHS:
     - /usr/local/lib/ruby/gems/3.0.0
     - /Users/tgermer/.gem/ruby/3.0.0
     - /usr/local/Cellar/ruby/3.0.1/lib/ruby/gems/3.0.0

gem install --user-install bundler jekyll终端之后出现以下内容:

    tgermer@HM02283GMBP2016 teamclusion % gem install --user-install bundler jekyll
Successfully installed bundler-2.2.15
Parsing documentation for bundler-2.2.15
Done installing documentation for bundler after 3 seconds
Building native extensions. This could take a while...
ERROR:  Error installing jekyll:
    ERROR: Failed to build gem native extension.

    current directory: /Users/tgermer/.gem/ruby/3.0.0/gems/ffi-1.15.0/ext/ffi_c
/usr/local/opt/ruby/bin/ruby -I /usr/local/Cellar/ruby/3.0.1/lib/ruby/3.0.0 -r ./siteconf20210408-7443-w0jyji.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
    --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=/usr/local/Cellar/ruby/3.0.1/bin/$(RUBY_BASE_NAME)
    --with-ffi_c-dir
    --without-ffi_c-dir
    --with-ffi_c-include
    --without-ffi_c-include=${ffi_c-dir}/include
    --with-ffi_c-lib
    --without-ffi_c-lib=${ffi_c-dir}/lib
    --enable-system-libffi
    --disable-system-libffi
    --with-libffi-config
    --without-libffi-config
    --with-pkg-config
    --without-pkg-config
/usr/local/Cellar/ruby/3.0.1/lib/ruby/3.0.0/mkmf.rb:471:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /usr/local/Cellar/ruby/3.0.1/lib/ruby/3.0.0/mkmf.rb:564:in `try_link0'
    from /usr/local/Cellar/ruby/3.0.1/lib/ruby/3.0.0/mkmf.rb:582:in `try_link'
    from /usr/local/Cellar/ruby/3.0.1/lib/ruby/3.0.0/mkmf.rb:684:in `try_ldflags'
    from /usr/local/Cellar/ruby/3.0.1/lib/ruby/3.0.0/mkmf.rb:1851:in `pkg_config'
    from extconf.rb:9:in `system_libffi_usable?'
    from extconf.rb:42:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/tgermer/.gem/ruby/3.0.0/extensions/x86_64-darwin-20/3.0.0/ffi-1.15.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/tgermer/.gem/ruby/3.0.0/gems/ffi-1.15.0 for inspection.
Results logged to /Users/tgermer/.gem/ruby/3.0.0/extensions/x86_64-darwin-20/3.0.0/ffi-1.15.0/gem_make.out
1 gem installed

/Users/tgermer/.gem/ruby/3.0.0/extensions/x86_64-darwin-20/3.0.0/ffi-1.15.0/mkmf.log

"pkg-config --exists libffi"
| pkg-config --libs libffi
=> "-lffi\n"
"clang -fdeclspec -o conftest -I/usr/local/Cellar/ruby/3.0.1/include/ruby-3.0.0$

You have not agreed to the Xcode license agreements, please run 'sudo xcodebuil$
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */

任何人都可以帮助解决问题吗?谢谢

标签: rubyjekyllmacos-big-sur

解决方案


看来日志已经给你答案了:

您尚未同意 Xcode 许可协议,请运行 'sudo xcodebuil[...]

该行似乎在您粘贴的日志中被剪切,但应该是

sudo xcodebuild -license accept

推荐阅读