Error installing nokogiri 1.6.0 on mac (libxml2)

徘徊边缘 提交于 2019-11-28 21:15:04

I found the answer in another thread. The workaround I used is to tell Nokogiri to use the system libraries instead:

NOKOGIRI_USE_SYSTEM_LIBRARIES=1 bundle install

Create file build_nokogiri (or whatever) and fill in with:

#!/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

Give this file permission to execute.

Execute file.

This will automatically resolve dependencies installed using brew.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!