将所有数据传输到新的mac后,安装gem时出错:错误:无法生成gem本机扩展

时间:2018-12-17 17:43:17

标签: ruby rubygems fastlane

设置新的Mac并从旧的Mac传输数据后,某些gem无法安装,并且在尝试安装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 */

我已经研究了几个小时,现在不知道该怎么办。尝试安装另一个gem fastlane时,我附加了另一个类似的错误:

$ 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-select --install安装Xcode开发人员工具。

有人可能暗示要做什么吗?

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

1 个答案:

答案 0 :(得分:1)

我想我通过删除/ usr / local / include /文件夹中的String.h文件来修复它。这个SO问题中也写着相同的内容:gem install libxml-ruby: fatal error: 'plist/Node.h' file not found

命令brew doctor告诉我/ usr / local / include /文件夹中有很多文件可能会被删除。我删除了文件String.h,并将所有其他文件保留在原处。这样就解决了。

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