Error installing nokogiri: Failed to build gem native extension & libiconv is missing (OSX)

前端 未结 15 1392
无人共我
无人共我 2020-12-07 18:25

I try to clone this repo and run bundle install. The bundle process failed and throw this error:

    ...
    Installing nokogiri 1.6.2.1 with na         


        
相关标签:
15条回答
  • 2020-12-07 19:04

    I had same issue while updating to xcode 10, I resolved it with following steps :

    1. xcode-select --install
    2. bundle install --deployment
    3. gem install nokogiri
    0 讨论(0)
  • 2020-12-07 19:08

    If you're using bundle:

    brew install libxml2
    
    # If using Bundle
    bundle config build.nokogiri --use-system-libraries \
      --with-xml2-include=$(brew --prefix libxml2)/include/libxml2
    bundle install
    

    from http://www.nokogiri.org/tutorials/installing_nokogiri.html

    0 讨论(0)
  • 2020-12-07 19:08

    I did everything in the other answers, but had to do one more thing:

    1. Open Xcode
    2. Click "Agree"
    3. Wait a bit, close Xcode
    4. Rejoice
    0 讨论(0)
  • 2020-12-07 19:09

    Spencer's answer worked for me, but I also needed to use the -n parameter to overcome the permission issue documented here.

    So in the end, the command that worked for me was:

    gem install -n /usr/local/bin nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxml2 --use-system-libraries
    
    0 讨论(0)
  • 2020-12-07 19:09

    This helped me fix this

    • I reinstalled Xcode and directed xcode-select to its path
    sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
    

    ref: https://stackoverflow.com/a/17980786/3861525

    0 讨论(0)
  • 2020-12-07 19:11

    It may also be an issue with the anaconda version of some of the libs.

    $ conda deactivate
    $ gem uninstall nokogiri
    $ gem install nokogiri
    $ conda activate base
    

    worked for me.

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