我遇到以下情況WRT nokogiri在運行OSX-10.9.5的MacBook Pro中,並且已經安裝了X-Code 6.2以及相關的命令行工具。OSX-10.9.5和Nokogiri RubyGem 1.6.7.1
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 */
雖然成功的創業板建設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的反覆無稽之談。
這個答案的困難是,安裝引入nokogiri作爲全系統的寶玉成功雖然需要BS ARCHFLAG設置,但在Bundler作爲項目的一部分安裝時會失敗。行爲上的差異是問題。爲什麼一個人在沒有任何環境變化的情況下成功,另一個人在同一臺主機上失敗呢?此外,重新鏈接'dyld'不會幫助Bundler找到'xcodebuild'程序。我相信問題在於Bundler,但我不知道它是什麼。 –