【问题标题】:Error installing nokogiri 1.6.0 on mac (libxml2)在 mac (libxml2) 上安装 nokogiri 1.6.0 时出错
【发布时间】:2013-07-25 16:02:21
【问题描述】:

更新:已修复

我在另一个帖子中找到了答案。我使用的解决方法是告诉 Nokogiri 改用系统库:

NOKOGIRI_USE_SYSTEM_LIBRARIES=1 bundle install

====

尝试在 Mac 上安装 nokogiri 1.6.0。使用以前的版本,我没有问题。但是 1.6.0 拒绝安装。这是错误:

    Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /Users/josenriq/.rvm/rubies/ruby-1.9.3-head/bin/ruby extconf.rb
Extracting libxml2-2.8.0.tar.gz into tmp/i686-apple-darwin11/ports/libxml2/2.8.0... ERROR
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Archive contains obsolescent base-64 headers
tar: Read 3 bytes from /Users/josenriq/.rvm/gems/ruby-1.9.3-head@wdi/gems/nokogiri-1.6.0/ports/archives/libxml2-2.8.0.tar.gz
tar: Error exit delayed from previous errors
*** 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=/Users/josenriq/.rvm/rubies/ruby-1.9.3-head/bin/ruby
/Users/josenriq/.rvm/rubies/ruby-1.9.3-head/lib/ruby/gems/1.9.1/gems/mini_portile-0.5.1/lib/mini_portile.rb:234:in `extract_file': Failed to complete extract task (RuntimeError)
    from /Users/josenriq/.rvm/rubies/ruby-1.9.3-head/lib/ruby/gems/1.9.1/gems/mini_portile-0.5.1/lib/mini_portile.rb:34:in `block in extract'
    from /Users/josenriq/.rvm/rubies/ruby-1.9.3-head/lib/ruby/gems/1.9.1/gems/mini_portile-0.5.1/lib/mini_portile.rb:32:in `each'
    from /Users/josenriq/.rvm/rubies/ruby-1.9.3-head/lib/ruby/gems/1.9.1/gems/mini_portile-0.5.1/lib/mini_portile.rb:32:in `extract'
    from /Users/josenriq/.rvm/rubies/ruby-1.9.3-head/lib/ruby/gems/1.9.1/gems/mini_portile-0.5.1/lib/mini_portile.rb:98:in `cook'
    from extconf.rb:101:in `block in <main>'
    from extconf.rb:119:in `call'
    from extconf.rb:119:in `block in <main>'
    from extconf.rb:109:in `tap'
    from extconf.rb:109:in `<main>'


Gem files will remain installed in /Users/josenriq/.rvm/gems/ruby-1.9.3-head@wdi/gems/nokogiri-1.6.0 for inspection.
Results logged to /Users/josenriq/.rvm/gems/ruby-1.9.3-head@wdi/gems/nokogiri-1.6.0/ext/nokogiri/gem_make.out

似乎与 libxml2 tar 文件无法解压有关。

有什么想法吗?我已经做了大约 8 个小时的研究,但无济于事。谢谢!

【问题讨论】:

    标签: ruby gem nokogiri libxml2


    【解决方案1】:

    我在另一个帖子中找到了答案。我使用的解决方法是告诉 Nokogiri 改用系统库:

    NOKOGIRI_USE_SYSTEM_LIBRARIES=1 bundle install
    

    【讨论】:

    • 能够使用这个答案在 osx 10.6.8 ruby​​2.1.0 上升级到 nokogiri 1.6.1。
    【解决方案2】:

    创建文件 build_nokogiri(或其他)并填写:

    #!/usr/bin/env ruby
    
    class Version
      attr_reader :major, :minor, :patch, :base
      def initialize( str )
        @base = str
        base = File.basename str
        @major, @minor, @patch = base.split('.').map &:to_i
      end
    
      def <=>(other)
        return -1 if major < other.major
        return 1 if major > other.mahor
        return -1 if minor < other.minor
        return 1 if minor > other.minor
        return -1 if patch < other.patch
        return 1 if patch > other.patch
        0
      end
    
      def to_s
        "##{self.class.name}{#@major #@minor #@patch  #@base}"
      end
      alias inspect to_s
      alias dir base
    
      def version
        [major,minor,patch].compact.join('.')
      end
    end
    
    class Lookup < Version
      class << self
        attr_accessor :prefix
      end
      def self.find
        Dir[ "/usr/local/Cellar/#{ full_name }/*" ].map { |c| new c }.sort.first
      end
    
      def self.full_name
        [prefix, name.downcase].compact.join('')
      end
    
      %w{ include lib }.each { |m| define_method("#{m}_path") { "#{ base }/#{ m }" } }
    
      def args
        %w{ include lib }.map do |c|
          "--with-#{ self.class.name.downcase }-#{c}=#{ send("#{ c }_path") }"
        end.join(' ')
      end
    end
    
    class XML2 < Lookup
      self.prefix = 'lib'
      def include_path
        "#{super}/#{ self.class.full_name }"
      end
    end
    
    class XSLT < Lookup
      self.prefix = 'lib'
      def args
        "--with-xslt-dir=#{ dir }"
      end
    end
    
    class Iconv < Lookup
      self.prefix = 'lib'
    end
    
    puts "Found:"
    a = [ XML2.find, XSLT.find, Iconv.find ]
    
    puts a
    
    s="  gem install nokogiri -- #{ a.map(&:args).join(' ') } --use-system-libraries"
    puts s
    
    exec s
    

    授予此文件执行权限。

    执行文件。

    这将自动解析使用 brew 安装的依赖项。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-19
      • 2013-12-07
      • 2015-11-13
      • 1970-01-01
      • 2011-09-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多