在 macOS Sierra 上安装 jekyll 失败

Posted

技术标签:

【中文标题】在 macOS Sierra 上安装 jekyll 失败【英文标题】:Installation of jekyll on macOS Sierra fails 【发布时间】:2017-03-03 03:56:38 【问题描述】:

我正在尝试使用以下版本在 macOS 上安装 jekyll,并使用 ruby​​ 2.4.0p0 和 gem 2.6.10 安装 xcode 命令行工具

安装 jekyll 和 bundler

gem install jekyll bundler

命令的结果是

Fetching: public_suffix-2.0.5.gem (100%)
Successfully installed public_suffix-2.0.5
Fetching: addressable-2.5.0.gem (100%)
Successfully installed addressable-2.5.0
Fetching: colorator-1.1.0.gem (100%)
Successfully installed colorator-1.1.0
Fetching: sass-3.4.23.gem (100%)
Successfully installed sass-3.4.23
Fetching: jekyll-sass-converter-1.5.0.gem (100%)
Successfully installed jekyll-sass-converter-1.5.0
Fetching: rb-fsevent-0.9.8.gem (100%)
Successfully installed rb-fsevent-0.9.8
Fetching: ffi-1.9.17.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing jekyll:
    ERROR: Failed to build gem native extension.

    current directory: /usr/local/lib/ruby/gems/2.4.0/gems/ffi-1.9.17/ext/ffi_c
/usr/local/opt/ruby/bin/ruby -r ./siteconf20170303-1307-1slrb61.rb extconf.rb
checking for ffi.h... *** 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/2.4.0/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
    --with-libffi-config
    --without-libffi-config
    --with-pkg-config
    --without-pkg-config
/usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/mkmf.rb:457:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/mkmf.rb:588:in `try_cpp'
    from /usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/mkmf.rb:1095:in `block in have_header'
    from /usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/mkmf.rb:945:in `block in checking_for'
    from /usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/mkmf.rb:351:in `block (2 levels) in postpone'
    from /usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/mkmf.rb:321:in `open'
    from /usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/mkmf.rb:351:in `block in postpone'
    from /usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/mkmf.rb:321:in `open'
    from /usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/mkmf.rb:347:in `postpone'
    from /usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/mkmf.rb:944:in `checking_for'
    from /usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/mkmf.rb:1094:in `have_header'
    from extconf.rb:16:in `<main>'

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

  /usr/local/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0/ffi-1.9.17/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/local/lib/ruby/gems/2.4.0/gems/ffi-1.9.17 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0/ffi-1.9.17/gem_make.out
Fetching: bundler-1.14.5.gem (100%)
Successfully installed bundler-1.14.5
Parsing documentation for bundler-1.14.5
Installing ri documentation for bundler-1.14.5
Done installing documentation for bundler after 4 seconds
1 gem installed

日志文件 mkmf.log 的内容

package configuration for libffi is not found
"clang -o conftest -I/usr/local/Cellar/ruby/2.4.0/include/ruby-2.4.0/x86_64-darwin16 -I/usr/local/Cellar/ruby/2.4.0/include/ruby-2.4.0/ruby/backward -I/usr/local/Cellar/ruby/2.4.0/include/ruby-2.4.0 -I.  -I/usr/local/opt/libyaml/include -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/usr/local/Cellar/ruby/2.4.0/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib     -lruby.2.4.0  -lpthread -ldl -lobjc "
2017-03-03 09:09 xcodebuild[1311] (FSEvents.framework) FSEventStreamStart: ERROR: FSEvents_connect() => (ipc/send) invalid destination port (268435459)
2017-03-03 09:09 xcodebuild[1311] (FSEvents.framework) FSEventStreamInvalidate(): failed assertion 'streamRef != NULL'

2017-03-03 09:09 xcodebuild[1311] (FSEvents.framework) FSEventStreamRelease(): failed assertion 'streamRef != NULL'

2017-03-03 09:09:01.029 xcodebuild[1311:92957]  DVTFilePathFSEvents: Failed to start fs event stream.
sh: line 1:  1313 Abort trap: 6           /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk / -find clang 2> /dev/null
clang: error: unable to find utility "clang", not a developer tool or in PATH
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: 
5:   return 0;
6: 
/* end */

【问题讨论】:

【参考方案1】:

我正在寻找解决方案来修复 clang: error: unable to find utility "clang", not a developer tool or in PATH

发现 Xcode 找不到自己的命令行工具。 这个link 为我修好了。

【讨论】:

以上是关于在 macOS Sierra 上安装 jekyll 失败的主要内容,如果未能解决你的问题,请参考以下文章

在 OS X 10.11 El Capitan、macOS 10.12 Sierra、macOS 10.13 High Sierra (< 10.13.3) 上安装 pecl 和 pear

markdown 在macOS High Sierra上安装多个Java版本

markdown 在macOS High Sierra上安装多个Java版本

[黑苹果]:如何在Virtualbox上安装macOS Sierra?

markdown 在High Sierra上安装Windows 10(macOS 10.13.2)

Xcode 无法安装在“macOS Sierra”上,因为需要 macOS 版本 10.14.3 或更高版本