【问题标题】:OSX-10.9.5 and Nokogiri RubyGem 1.6.7.1OSX-10.9.5 和 Nokogiri RubyGem 1.6.7.1
【发布时间】:2016-04-05 00:44:37
【问题描述】:

我在运行 OSX-10.9.5 并安装了 X-Code 6.2 和相关命令行工具的 MacBook Pro 上遇到以下情况 WRT nokogiri。

ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future

sudo gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2
Building native extensions with: '--with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2'
This could take a while...
Successfully installed nokogiri-1.6.7.1
Parsing documentation for nokogiri-1.6.7.1
Installing ri documentation for nokogiri-1.6.7.1
Done installing documentation for nokogiri after 13 seconds
1 gem installed

但是,紧接着就会发生这种情况:

bundle config build.nokogiri  --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2

bundle update
. . .
Installing nokogiri 1.6.7.1 (was 1.6.7) with native extensions

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

    /opt/local/bin/ruby2.2 -r ./siteconf20151230-65520-1ws37n2.rb extconf.rb --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2
checking if the C compiler accepts ... *** 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=/opt/local/bin/$(RUBY_BASE_NAME)2.2
    --help
    --clean
/opt/local/lib/ruby2.2/2.2.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /opt/local/lib/ruby2.2/2.2.0/mkmf.rb:571:in `block in try_compile'
    from /opt/local/lib/ruby2.2/2.2.0/mkmf.rb:522:in `with_werror'
    from /opt/local/lib/ruby2.2/2.2.0/mkmf.rb:571:in `try_compile'
    from extconf.rb:80:in `nokogiri_try_compile'
    from extconf.rb:87:in `block in add_cflags'
    from /opt/local/lib/ruby2.2/2.2.0/mkmf.rb:619:in `with_cflags'
    from extconf.rb:86:in `add_cflags'
    from extconf.rb:336:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/byrnejb/Projects/hll_th/hll_th_proforma/libexec/bundle/lib/gems/nokogiri-1.6.7.1 for inspection.
Results logged to /Users/byrnejb/Projects/hll_th/hll_th_proforma/libexec/bundle/lib/extensions/x86_64-darwin-13/2.2.0/nokogiri-1.6.7.1/gem_make.out
. . .

检查捆绑器失败构建的 mkmf 日志揭示了这一点:

cat .//libexec/bundle/lib/extensions/x86_64-darwin-13/2.2.0/nokogiri-1.6.7.1/mkmf.log

"/usr/bin/clang -o conftest -I/opt/local/include/ruby-2.2.0/x86_64-darwin13 -I/opt/local/include/ruby-2.2.0/ruby/backward -I/opt/local/include/ruby-2.2.0 -I. -I/opt/local/include -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -pipe -Os -fno-common  conftest.c  -L/opt/local/lib -L. -L/opt/local/lib -L. -L/opt/local/lib -Wl,-headerpad_max_install_names -fstack-protector -L/opt/local/lib    -arch x86_64   -lruby.2.2.0  -lpthread -ldl -lobjc  "
dyld: Symbol not found: __cg_jpeg_resync_to_restart
  Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
  Expected in: /opt/local/lib/libJPEG.dylib
 in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
clang: error: unable to locate xcodebuild, please make sure the path to the Xcode folder is set correctly!
clang: error: You can set the path to the Xcode folder using /usr/bin/xcode-select -switch
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

虽然成功的 gem build mkmf 日志显示如下:

cat /opt/local/lib/ruby2.2//gems/2.2.0/extensions/x86_64-darwin-13/2.2.0/nokogiri-1.6.7.1/mkmf.log

"/usr/bin/clang -o conftest -I/opt/local/include/ruby-2.2.0/x86_64-darwin13 -I/opt/local/include/ruby-2.2.0/ruby/backward -I/opt/local/include/ruby-2.2.0 -I. -I/opt/local/include -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -pipe -Os -fno-common  conftest.c  -L/opt/local/lib -L. -L/opt/local/lib -L. -L/opt/local/lib -Wl,-headerpad_max_install_names -fstack-protector -L/opt/local/lib    -arch x86_64   -lruby.2.2.0  -lpthread -ldl -lobjc  "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

寻找xcodebuild 揭示了这一点:

sudo find / -name xcodebuild
Password:
/Applications/Xcode.app/Contents/Developer/usr/bin/
/Developer-3.2.6/usr/bin/xcodebuild
/private/var/root/Library/Caches/xcodebuild
/usr/bin/xcodebuild

which xcodebuild
/usr/bin/xcodebuild

检查xcode-select -p 显示:

xcode-select -p
/Applications/Xcode.app/Contents/Developer

尊重 dyld 错误:

dyld: Symbol not found: __cg_jpeg_resync_to_restart
  Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
  Expected in: /opt/local/lib/libJPEG.dylib

我已验证没有名为DYLD_LIBRARY_PATH 的环境变量。但也没有/opt/local/lib/libJPEG.dylib。但是有一个/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib

有没有人知道捆绑器构建发生了什么?

我厌倦了在 OSX 上构建 nokogiri 时这种反复出现的废话。

【问题讨论】:

    标签: ruby-on-rails ruby rubygems nokogiri bundler


    【解决方案1】:

    您的问题似乎与https://www.alfresco.com/blogs/developer/2012/12/11/homebrew-share-thumbnails-and-previews-on-os-x/ 中指定的问题相似

    分辨率可以重新链接图片dylib:

    $ cd /opt/local/lib
    $ rm libgif.dylib
    $ ln -s path/to/libGIF libGIF.dylib
    $ rm libjpeg.dylib
    $ ln -s path/to/libJPEG libJPEG.dylib
    $ rm libtiff.dylib
    $ ln -s path/to/libTIFF libTIFF.dylib
    $ rm libpng.dylib
    $ ln -s path/to/libPng libPng.dylib
    

    【讨论】:

    • 这个答案的困难在于将 nokogiri 作为系统范围的 gem 安装成功,尽管需要 BS ARCHFLAG 设置,但是当 Bundler 作为项目的一部分安装时失败。行为上的差异是问题所在。为什么在不改变环境的情况下,在同一台主机上一个成功,另一个失败?此外,重新链接 dyld 不会帮助 Bundler 找到 xcodebuild 程序。我相信问题出在 Bundler 上,但我不知道它是什么。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    • 2015-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多