Error - “gem install rails” - libxml2 is missing

后端 未结 8 1759
滥情空心
滥情空心 2021-01-05 02:14

I\'ve been working through the Rails install instructions (http://railsapps.github.io/installrubyonrails-mac.html) and everything was okay up until I got to gem instal

相关标签:
8条回答
  • 2021-01-05 02:40

    This worked for me (based on this Github thread):

    gem install nokogiri -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib/
    

    As a note, my issue was:

    ...
    checking for main() in -llzma... yes
    checking for xmlParseDoc() in libxml/parser.h... no
    checking for xmlParseDoc() in -lxml2... no
    checking for xmlParseDoc() in -llibxml2... no
    -----
    libxml2 is missing.  Please locate mkmf.log to investigate how it is failing.
    -----
    *** 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=/Users/seanshadmand/.rvm/rubies/ruby-2.1.1/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
        --with-xml2lib
        --without-xml2lib
        --with-libxml2lib
        --without-libxml2lib
    
    To see why this extension failed to ...
    
    extconf failed, exit code 1
    
    0 讨论(0)
  • 2021-01-05 02:41

    Try using this:

    sudo gem install rails -- --use-system-libraries --with-xml=/usr/local/Cellar/libxml2/
    
    0 讨论(0)
  • 2021-01-05 02:53

    I had the same problem when I try:

    gem install libxml-ruby -v '3.0.0
    

    Run the following solved the issue on Mac for me:

    gem update --system
    
    xcode-select --install
    
    gem install nokogiri
    

    See installing nokogiri for more details

    0 讨论(0)
  • 2021-01-05 02:55

    For some reason nokogiri build process for libxml2 will misplace build version.

    Instead of lib/ it will to go lib64/. Nokogiri will then look for it in the wrong directory.

    More info here: https://github.com/sparklemotion/nokogiri/issues/1334

    0 讨论(0)
  • 2021-01-05 02:59

    You don't have the required library, and it is so easy to google solution:

     brew install libxml2
    
    0 讨论(0)
  • 2021-01-05 03:03

    It worked for me as Simar has mentioned.

    sudo gem install rails -- --use-system-libraries --with-xml=/usr/local/Cellar/libxml2/
    

    And if you were having troubles install it on Mac please check out here. https://gorails.com/setup/osx/10.11-el-capitan

    Also if you could not find /usr/local/Cellar/libxml2/ existing, you may need to homebrew it.

    brew install libxml2
    

    If you are installing it on a newly installed OS X EL CAPITAN as I do, you probably find homebrew telling you that libxml2 is installed already and brew will not replace the existing libxml2 with it's newly installed one which is at /usr/local/Cellar/libxml2/, which is the one we really should link the libraries to. Since the system default libxml2 would not link successfully.

    0 讨论(0)
提交回复
热议问题