【问题标题】:How to install Nokogiri on Mac OS X El Capitan如何在 Mac OS X El Capitan 上安装 Nokogiri
【发布时间】:2017-01-25 01:23:42
【问题描述】:

我一直在尝试安装 Nokogiri,但最终出现错误。 我有一个 Jekyll 站点,托管在 Github 上,当我在克隆站点后尝试 bundle install 时,安装 Nokogiri 时出现错误。

  1. 首先我尝试了这两个:

    bundle config build.nokogiri --use-system-libraries
    bundle install.
    

    这给了我以下错误:

    Errno::EACCES: Permission denied - /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-15/2.0.0/nokogiri-1.6.8/gem_make.out
    An error occurred while installing nokogiri (1.6.8), and Bundler cannot continue.
    Make sure that `gem install nokogiri -v '1.6.8'` succeeds before bundling.
    
  2. 在我的第二次安装尝试中,我使用了:

    gem install nokogiri 
    

    这导致我收到以下错误消息:

    Building native extensions.  This could take a while...
        ERROR:  Error installing nokogiri:
            ERROR: Failed to build gem native extension.
    
            current directory: /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.8/ext/nokogiri
        /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20160916-79204-14q5l5.rb extconf.rb
        Using pkg-config version 1.1.7
        checking if the C compiler accepts ... yes
        checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
        Building nokogiri using packaged libraries.
        Using mini_portile version 2.1.0
        checking for iconv.h... yes
        checking for gzdopen() in -lz... yes
        checking for iconv... yes
        ************************************************************************
        IMPORTANT NOTICE:
    
        Building Nokogiri with a packaged version of libxml2-2.9.4.
    
        Team Nokogiri will keep on doing their best to provide security
        updates in a timely manner, but if this is a concern for you and want
        to use the system library instead; abort this installation process and
        reinstall nokogiri as follows:
    
            gem install nokogiri -- --use-system-libraries
                [--with-xml2-config=/path/to/xml2-config]
                [--with-xslt-config=/path/to/xslt-config]
    
        If you are using Bundler, tell it to use the option:
    
            bundle config build.nokogiri --use-system-libraries
            bundle install
    
        Note, however, that nokogiri is not fully compatible with arbitrary
        versions of libxml2 provided by OS/package vendors.
        ************************************************************************
        Extracting libxml2-2.9.4.tar.gz into tmp/x86_64-apple-darwin15/ports/libxml2/2.9.4... OK
        Running 'configure' for libxml2 2.9.4... OK
        Running 'compile' for libxml2 2.9.4... ERROR, review '/Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.8/ext/nokogiri/tmp/x86_64-apple-darwin15/ports/libxml2/2.9.4/compile.log' to see what happened. Last lines are:
        ========================================================================
          CCLD     libxml2.la
          CC       testdso.lo
          CCLD     testdso.la
          CC       xmllint.o
          CCLD     xmllint
        ld: warning: ignoring file /usr/local/Cellar/xz/5.2.2/lib/liblzma.dylib, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/Cellar/xz/5.2.2/lib/liblzma.dylib
        Undefined symbols for architecture i386:
          "_lzma_auto_decoder", referenced from:
              _xz_head in libxml2.a(xzlib.o)
          "_lzma_code", referenced from:
              _xz_decomp in libxml2.a(xzlib.o)
          "_lzma_end", referenced from:
              ___libxml2_xzclose in libxml2.a(xzlib.o)
          "_lzma_properties_decode", referenced from:
              _is_format_lzma in libxml2.a(xzlib.o)
        ld: symbol(s) not found for architecture i386
        clang: error: linker command failed with exit code 1 (use -v to see invocation)
        make[2]: *** [xmllint] Error 1
        make[1]: *** [all-recursive] Error 1
        make: *** [all] Error 2
        ========================================================================
        *** 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
            --without-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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
            --help
            --clean
            --use-system-libraries
            --enable-static
            --disable-static
            --with-zlib-dir
            --without-zlib-dir
            --with-zlib-include
            --without-zlib-include=${zlib-dir}/include
            --with-zlib-lib
            --without-zlib-lib=${zlib-dir}/lib
            --enable-cross-build
            --disable-cross-build
        /Library/Ruby/Gems/2.0.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:366:in `block in execute': Failed to complete compile task (RuntimeError)
            from /Library/Ruby/Gems/2.0.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:337:in `chdir'
            from /Library/Ruby/Gems/2.0.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:337:in `execute'
            from /Library/Ruby/Gems/2.0.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:111:in `compile'
            from /Library/Ruby/Gems/2.0.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:150:in `cook'
            from extconf.rb:364:in `block (2 levels) in process_recipe'
            from extconf.rb:257:in `block in chdir_for_build'
            from extconf.rb:256:in `chdir'
            from extconf.rb:256:in `chdir_for_build'
            from extconf.rb:363:in `block in process_recipe'
            from extconf.rb:262:in `tap'
            from extconf.rb:262:in `process_recipe'
            from extconf.rb:555:in `<main>'
    
        To see why this extension failed to compile, please check the mkmf.log which can be found here:
    
          /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-15/2.0.0/nokogiri-1.6.8/mkmf.log
    
        extconf failed, exit code 1
    
        Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.8 for inspection.
        Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-15/2.0.0/nokogiri-1.6.8/gem_make.out
    

【问题讨论】:

  • 这在我的安装中解决了:stackoverflow.com/a/29021223
  • @lem0nlite 恐怕没用,不过还是谢谢!我在顶部更新了一条收到的新错误消息。

标签: xcode macos rubygems jekyll


【解决方案1】:

使用rbenv和RVM升级Ruby并使用命令后问题解决:

bundle install --path vendor/bundle

【讨论】:

  • 由于 RVM 和 rbenv 旨在解决相同的问题并且可能会发生冲突,因此我建议使用一个而不是同时使用两个。
  • rbenv 和 RVM 将争夺控制权。选择一个并使用它。来自the rbenv installation notes"rbenv is incompatible with RVM. Please make sure to fully uninstall RVM and remove any references to it from your shell initialization files before installing rbenv."
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-12-15
  • 2016-04-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多