尝试在 macOS Catalina 上安装 Jekyll 时构建 libffi gem 本机扩展时出现问题

Issues building the libffi gem native extension when trying to install Jekyll on macOS Catalina

编辑:如果您想完成所有步骤,我在我的博客 here 上写了一个更详细的解决方案。

我正在尝试通过 gem install Jekyll 在 macOS Catalina 上使用 Ruby 通过自制软件安装并位于 /usr/local/opt/ruby/bin/ruby 安装 Jekyll,我 运行 进入以下错误

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/Users/foobar/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/ffi-1.9.21/ext/ffi_c
/Users/foobar/.rbenv/versions/2.5.1/bin/ruby -r ./siteconf20181118-49440-k8mjki.rb
extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... no
checking for shlwapi.h... no
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
creating extconf.h
creating Makefile

current directory:
/Users/foobar/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/ffi-1.9.21/ext/ffi_c
make "DESTDIR=" clean

current directory:
/Users/foobar/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/ffi-1.9.21/ext/ffi_c
make "DESTDIR="
Running autoreconf for libffi
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal -I m4 --output=aclocal.m4t
Can't exec "aclocal": No such file or directory at
/usr/local/Cellar/autoconf/2.69/share/autoconf/Autom4te/FileUtils.pm line 326.
autoreconf: failed to run aclocal: No such file or directory
make: ***
["/Users/foobar/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/ffi-1.9.21/ext/ffi_c/libffi-x86_64-darwin18"/.libs/libffi_convenience.a]
Error 1

make failed, exit code 2

Gem files will remain installed in
/Users/foobar/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/ffi-1.9.21 for inspection.
Results logged to
/Users/foobar/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-18/2.5.0-static/ffi-1.9.21/gem_make.out

An error occurred while installing ffi (1.9.21), and Bundler cannot continue.

我已经尝试通过 xcode-select --install 更新我的 Xcode 命令行工具,但我收到了以下消息:

xcode-select: error: command line tools are already installed, use "Software Update" to install updates

有谁知道如何在我的机器上构建 libffi 以便 Jekyll 可以将其用作依赖项?

啊啊啊我想通了!感谢@ffleming here。这是您需要做的:

  1. 使用 brew reinstall libffi
  2. 在 brew 上重新安装 libffi
  3. 将新的 brew 安装的 libffi 标志添加到您的 shell 实例,例如
export LDFLAGS="-L/usr/local/opt/libffi/lib"
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
  1. 运行 gem install jekyll 你应该被排序了!