升级到macOS后,Mojave gem更新失败

Joz*_*eld 20 macos rubygems

构建原生扩展.这可能需要一段时间...错误:安装libxml-ruby时出错:错误:无法构建gem本机扩展.

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

    current directory: /Library/Ruby/Gems/2.3.0/gems/libxml-ruby-3.1.0/ext/libxml
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20180926-80978-eoqfjh.rb extconf.rb
checking for libxml/xmlversion.h in /opt/include/libxml2,/opt/local/include/libxml2,/usr/local/include/libxml2,/usr/include/libxml2... no
*** 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.3/usr/bin/$(RUBY_BASE_NAME)
    --with-xml2-config
    --without-xml2-config
    --with-xml2-dir
    --without-xml2-dir
    --with-xml2-include
    --without-xml2-include=${xml2-dir}/include
    --with-xml2-lib
    --without-xml2-lib=${xml2-dir}/lib
 extconf failure: need libxml2.

    Install the library or try one of the following options to extconf.rb:

      --with-xml2-config=/path/to/xml2-config
      --with-xml2-dir=/path/to/libxml2
      --with-xml2-lib=/path/to/libxml2/lib
      --with-xml2-include=/path/to/libxml2/include


To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/libxml-ruby-3.1.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/libxml-ruby-3.1.0 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/libxml-ruby-3.1.0/gem_make.out
Updating nokogiri
Building native extensions. This could take a while...
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/bin directory.
Run Code Online (Sandbox Code Playgroud)

/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20180926-80978-eoqfjh.rb extconf.rb检查/ opt/include/libxml2中的libxml/xmlversion.h,/ opt/local/include/libxml2,/ usr/local/include/libxml2,/ usr/include/libxml2 ... no *extconf.rb失败* 由于某些原因无法创建Makefile,可能缺少必要的库和/或头.检查mkmf.log文件以获取更多详细信息.您可能需要配置选项.

提供的配置选项: - 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.3/usr/bin/$(RUBY_BASE_NAME) - with-xml2-config --without-xml2-config --with-xml2- dir --without-xml2-dir --with-xml2-include --without-xml2-include = $ {xml2-dir}/include --with-xml2-lib --without-xml2-lib = $ {xml2- dir}/lib extconf失败:需要libxml2.

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

    current directory: /Library/Ruby/Gems/2.3.0/gems/libxml-ruby-3.1.0/ext/libxml
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20180926-80978-eoqfjh.rb extconf.rb
checking for libxml/xmlversion.h in /opt/include/libxml2,/opt/local/include/libxml2,/usr/local/include/libxml2,/usr/include/libxml2... no
*** 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.3/usr/bin/$(RUBY_BASE_NAME)
    --with-xml2-config
    --without-xml2-config
    --with-xml2-dir
    --without-xml2-dir
    --with-xml2-include
    --without-xml2-include=${xml2-dir}/include
    --with-xml2-lib
    --without-xml2-lib=${xml2-dir}/lib
 extconf failure: need libxml2.

    Install the library or try one of the following options to extconf.rb:

      --with-xml2-config=/path/to/xml2-config
      --with-xml2-dir=/path/to/libxml2
      --with-xml2-lib=/path/to/libxml2/lib
      --with-xml2-include=/path/to/libxml2/include


To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/libxml-ruby-3.1.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/libxml-ruby-3.1.0 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/libxml-ruby-3.1.0/gem_make.out
Updating nokogiri
Building native extensions. This could take a while...
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/bin directory.
Run Code Online (Sandbox Code Playgroud)

要查看此扩展无法编译的原因,请查看mkmf.log,可在此处找到:

/Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/libxml-ruby-3.1.0/mkmf.log

extconf失败,退出代码1

Gem文件将保留在/Library/Ruby/Gems/2.3.0/gems/libxml-ruby-3.1.0中以供检查.结果记录到/Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/libxml-ruby-3.1.0/gem_make.out更新nokogiri构建本机扩展.这可能需要一段时间...错误:执行gem时...(Gem :: FilePermissionError)您没有/ usr/bin目录的写权限.

alo*_*les 55

该错误是由于macOS Mojave已停止放置标准头文件/usr/include,仅将它们保留在XCode目录中.

您可以通过运行来验证这一点,ls /usr/include并且很可能此目录不再存在.相反,通常运行的技巧xcode-select --install不会解决问题.

修复程序是运行Apple提供的旧版安装程序,它将安装头文件 /usr/include

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /


cod*_*mev 5

如果您使用自制软件,推荐的方法是告诉pkg-config它在哪里可以找到 libxml2 库:

brew reinstall libxml2
export PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig"
Run Code Online (Sandbox Code Playgroud)