将所有数据传输到新的MAC之后,安装GEM的错误:错误:无法构建GEM本机扩展



设置新的Mac并从我的旧数据传输数据后,一些宝石不会安装,我会收到错误消息,例如尝试安装SPIDR时的以下信息:

$ sudo gem install spidr
Password:
Fetching: mini_portile2-2.4.0.gem (100%)
Successfully installed mini_portile2-2.4.0
Fetching: nokogiri-1.9.0.gem (100%)
Building native extensions. This could take a while...
ERROR:  Error installing spidr:
    ERROR: Failed to build gem native extension.
    current directory: /usr/local/lib/ruby/gems/2.5.0/gems/nokogiri-1.9.0/ext/nokogiri
/usr/local/opt/ruby/bin/ruby -r ./siteconf20181217-24587-ul93i2.rb extconf.rb
checking if the C compiler accepts ... *** 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=/usr/local/Cellar/ruby/2.5.3_1/bin/$(RUBY_BASE_NAME)
    --help
    --clean
/usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:574:in `block in try_compile'
    from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:521:in `with_werror'
    from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:574:in `try_compile'
    from extconf.rb:138:in `nokogiri_try_compile'
    from extconf.rb:162:in `block in add_cflags'
    from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:632:in `with_cflags'
    from extconf.rb:161:in `add_cflags'
    from extconf.rb:412:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
  /usr/local/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-18/2.5.0/nokogiri-1.9.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /usr/local/lib/ruby/gems/2.5.0/gems/nokogiri-1.9.0 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-18/2.5.0/nokogiri-1.9.0/gem_make.out

我还在下面附上引用的mkmf.log文件的内容:

"clang -o conftest -I/usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/x86_64-darwin18 -I/usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby/backward -I/usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0 -I.  -I/usr/local/opt/libyaml/include -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -fno-common -pipe  conftest.c  -L. -L/usr/local/Cellar/ruby/2.5.3_1/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib     -lruby.2.5.3  -lpthread -ldl -lobjc  "
In file included from conftest.c:1:
In file included from /usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby.h:33:
In file included from /usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby/ruby.h:29:
/usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby/defines.h:131:11: warning: non-portable path to file '<String.h>'; specified path differs in case from file name on disk [-Wnonportable-include-path]
# include <string.h>
      ^~~~~~~~~~
      <String.h>
In file included from conftest.c:1:
In file included from /usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby.h:33:
In file included from /usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby/ruby.h:29:
In file included from /usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby/defines.h:131:
/usr/local/include/string.h:25:10: fatal error: 'plist/Node.h' file not found
#include <plist/Node.h>
     ^~~~~~~~~~~~~~
1 warning and 1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

我已经进行了相当长的时间研究,不知道该怎么办。尝试安装另一个宝石时,我正在附加另一个类似的错误:

$ sudo gem install fastlane
Password:
Building native extensions. This could take a while...
ERROR:  Error installing fastlane:
    ERROR: Failed to build gem native extension.
    current directory: /usr/local/lib/ruby/gems/2.5.0/gems/unf_ext-0.0.7.5/ext/unf_ext
/usr/local/opt/ruby/bin/ruby -r ./siteconf20181217-24788-1jgurro.rb extconf.rb
checking for -lstdc++... *** 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=/usr/local/Cellar/ruby/2.5.3_1/bin/$(RUBY_BASE_NAME)
    --with-static-libstdc++
    --without-static-libstdc++
    --with-stdc++lib
    --without-stdc++lib
/usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:541:in `try_link0'
    from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:559:in `try_link'
    from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:778:in `try_func'
    from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:1005:in `block in have_library'
    from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:948:in `block in checking_for'
    from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:350:in `block (2 levels) in postpone'
    from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:320:in `open'
    from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:350:in `block in postpone'
    from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:320:in `open'
    from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:346:in `postpone'
    from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:947:in `checking_for'
    from /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/2.5.0/mkmf.rb:1000:in `have_library'
    from extconf.rb:6:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
  /usr/local/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-18/2.5.0/unf_ext-0.0.7.5/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /usr/local/lib/ruby/gems/2.5.0/gems/unf_ext-0.0.7.5 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-18/2.5.0/unf_ext-0.0.7.5/gem_make.out

相应的mkmf.log内容:

"clang -o conftest -I/usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/x86_64-darwin18 -I/usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby/backward -I/usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0 -I.  -I/usr/local/opt/libyaml/include -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/usr/local/Cellar/ruby/2.5.3_1/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib     -lruby.2.5.3  -lpthread -ldl -lobjc "
In file included from conftest.c:1:
In file included from /usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby.h:33:
In file included from /usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby/ruby.h:29:
/usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby/defines.h:131:11: warning: non-portable path to file '<String.h>'; specified path differs in case from file name on disk [-Wnonportable-include-path]
# include <string.h>
          ^~~~~~~~~~
          <String.h>
In file included from conftest.c:1:
In file included from /usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby.h:33:
In file included from /usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby/ruby.h:29:
In file included from /usr/local/Cellar/ruby/2.5.3_1/include/ruby-2.5.0/ruby/defines.h:131:
/usr/local/include/string.h:25:10: fatal error: 'plist/Node.h' file not found
#include <plist/Node.h>
         ^~~~~~~~~~~~~~
1 warning and 1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

Xcode开发人员工具是使用Xcode-select-install安装的。

有人可能有提示该怎么办?

非常感谢您的任何帮助和最好的问候塞巴斯蒂安

我认为我通过删除/usr/usr/local/include/folder删除文件字符串。在这个问题中也写了同样的问题:gem安装libxml-ruby:致命错误:'plist/node.h'未找到

命令brew doctor告诉我,可能会删除的/usr/local/includ/folder中有很多文件。我删除了文件字符串。这修复了。

感谢大家发表评论并尝试提供帮助。

最新更新