gem install nokogiri -v'1.6.8.1'失败 [英] gem install nokogiri -v '1.6.8.1' fails

查看:138
本文介绍了gem install nokogiri -v'1.6.8.1'失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

构建一个新的Rails应用程序并解决nokogiri的问题。说试试 gem install nokogiri -v'1.6.8.1',它会在下面的输出中失败。我尝试删除Gemfile.lock,并从另一个没有问题的应用程序中使用Gemfile - bundle install 仍然失败。最初的失败是 bundle install ,它可以继续在其他应用程序中工作。



从控制台:

  gem install nokogiri -v'1.6。 8.1'
构建原生扩展。这可能需要一段时间...
错误:安装nokogiri时出错:
错误:无法构建gem原生扩展。

当前目录:〜/ .gem / ruby​​ / 2.3.1 / gems / nokogiri-1.6.8.1 / ext / nokogiri
〜/ .rubies / ruby​​-2.3.1 / bin / ruby -r ./siteconf20161008-60071-tmqi2l.rb extconf.rb
忽略byebug-6.0.2,因为它的扩展没有被构建。试试:gem pristine byebug --version 6.0.2
忽略byebug-3.4.0,因为它的扩展没有建立。试试:gem pristine byebug --version 3.4.0
检查C编译器是否接受... yes
检查C编译器是否接受-Wno-error = unused-command-line-argument-hard-错误在未来...没有
使用打包的库构建nokogiri。
使用mini_portile版本2.1.0
检查iconv.h ...是
在-lz中检查gzdopen()...是
使用--with检查iconv -opt- *标志...是
************************************* ***********************************
重要通知:

使用libxml2-2.9.4的打包版本构建Nokogiri。

Nokogiri团队将继续尽最大努力及时提供安全性
更新,但如果这是您的担忧并希望
使用系统库,放弃安装过程并
重新安装nokogiri,如下所示:

gem install nokogiri - --use-system-libraries
[--with-xml2-config = / path / to / xml2-config]
[--with-xslt-config = / path / to / xslt-config]

如果使用Bundler,请告诉它使用以下选项:

bundle config build.nokogiri --use-system-libraries
bundle install

但是请注意,nokogiri与任意
版本不完全兼容由OS /软件包供应商提供的libxml2。
********************************************** **************************
将libxml2-2.9.4.tar.gz解压缩到tmp / x86_64-apple-darwin16.1.0 /ports/libxml2/2.9.4 ... OK
为libxml2运行'configure'2.9.4 ... OK
为libxml2运行'compile'2.9.4 ...错误,复习'〜 /.gem/ruby/2.3.1/gems/nokogiri-1.6.8.1/ext/nokogiri/tmp/x86_64-apple-darwin16.1.0/ports/libxml2/2.9.4/compile.log'来查看发生了什么。最后一行是:
========================================== ==============================
unsigned short * in =(unsigned short *)inb;
^ ~~~~~~~~~~~~~~~~~~~~
encoding.c:815:27:warning:从'unsigned char *'转换为'unsigned short *'将所需的对齐从1增加到2 [-Wcast-align]
unsigned short * out =(unsigned short *)outb;
^ ~~~~~~~~~~~~~~~~~~~~生成警告。
CC error.lo
CC parserInternals.lo
CC parser.lo
CC tree.lo
CC hash.lo
CC list.lo
CC xmlIO.lo
xmlIO.c:1450:52:error:使用未声明的标识符'LZMA_OK'
ret =(__libxml2_xzclose((xzFile)context)== LZMA_OK)? 0:-1;
^
1产生的错误。
make [2]:*** [xmlIO.lo]错误1
make [1]:*** [all-recursive]错误1
make:*** [all]错误2
============================================ ============================
*** extconf.rb失败***
无法创建Makefile由于某种原因,可能缺少必要的
库和/或头文件。检查mkmf.log文件以获取更多详细信息。您可能
需要配置选项。

提供的配置选项:
--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 =〜/ .rubies / ruby​​-2.3.1 / bin / $(RUBY_BASE_NAME)
--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
〜/ .rubies / ruby​​-2.3.1 / lib / ruby​​ / gems / 2.3.0 / gems / mini_portile2-2.1.0 / lib / mini_portile2 / mini_portile.rb:366:在`block in execute'中:无法完成编译任务(RuntimeError)
from〜/ .rubies / ruby -2.3.1 / lib / ruby​​ / gems / 2.3.0 / gems / mini_portile2-2.1.0 / lib / mini_portile2 / mini_portile.rb:337:在〜/ .rubies / ruby​​-2.3中的`chdir'
.1 / lib / ruby​​ / gems / 2.3.0 / gems / mini_portile2-2.1.0 / lib / mini_portile2 / mini_portile.rb:337:在`execute'
from〜/ .rubies / ruby​​-2.3.1 /lib/ruby/gems/2.3.0/gems/mini_portile2-2.1.0/lib/mini_portile2/ mini_portile.rb:111:在`compile'
从〜/ .rubies / ruby​​-2.3.1 / lib / ruby​​ / gems / 2.3.0 / gems / mini_portile2-2.1.0 / lib / mini_portile2 / mini_portile。 rb:150:在`cook'
从extconf.rb:365:在`block(2个级别)in process_recipe'
从extconf.rb:258:在`block in chdir_for_build'
从extconf.rb:257:在`chdir'
从extconf.rb:257:在`chdir_for_build'
从extconf.rb:364:在`block in process_recipe'
from extconf。 rb:263:'tap'
from extconf.rb:263:'process_recipe'
from extconf.rb:556:in< main>'

To看看为什么这个扩展无法编译,请检查可以在这里找到的mkmf.log:

〜/ .gem / ruby​​ / 2.3.1 / extensions / x86_64-darwin-16 / 2.3.0 -static / nokogiri-1.6.8.1 / mkmf.log

extconf失败,退出代码1

Gem文件将保持安装在〜/ .gem / ruby​​ / 2.3.1 /gems/nokogiri-1.6.8.1进行检查。
结果记录到〜/ .gem / ruby​​ / 2.3.1 / extensions / x86_64-darwin-16 / 2.3.0-static / nokogiri-1.6.8.1 / gem_make.out

mkmf.log:

 clang -o conftest -I〜/ .rubies / ruby​​-2.3.1 / include / ruby​​-2.3.0 / x86_64-darwin16 -I〜/ .rubies / ruby​​-2.3.1 / include / ruby​​-2.3.0 / ruby​​ /向后--I〜/ .rubies / ruby​​-2.3.1 / include / ruby​​-2.3.0 -I。-I / usr / local / opt / openssl / include -I / usr / local / opt / readline / include -I / usr / local / opt / libyaml / include -I / usr / local / opt / gdbm / include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno -fast-math -ggdb3 -Wall -Wextra -Wno -unused-parameter -Wno-括号-Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wclaclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -pipe conftest.c -L。-L〜/ .rubies / ruby​​-2.3.1 / lib -L ​​/ usr / local / opt / openssl / lib -L / usr / local / opt / readline / lib -L / usr / local / opt / libyaml / lib -L ​​/ usr / local / opt / gdbm / lib -L。 -fstack-protector -L / usr / local / opt / openssl / lib -L ​​/ usr / local / opt / readline / lib -L ​​/ usr / local / opt / libyaml / lib -L ​​/ usr / local / opt / gdbm / lib -lruby-static-framework CoreFoundation -lpthread -ldl -lobjc
检查的程序是:
/ * begin * /
1:#includeruby.h
2:
3:int main(int argc,char ** argv)
4:{
5:return 0;
6:}
/ * end * /

clang -I〜/ .rubies / ruby​​-2.3.1 / include / ruby​​-2.3.0 / x86_64 -darwin16 -I〜/ .rubies / ruby​​-2.3.1 / include / ruby-2.3.0 / ruby​​ / backward -I〜/ .rubies / ruby​​-2.3.1 / include / ruby​​-2.3.0 -I。 -I / usr / local / opt / openssl / include -I / usr / local / opt / readline / include -I / usr / local / opt / libyaml / include -I / usr / local / opt / gdbm / include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno -unused-parameter -Wno-括号-Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer -with -Wwrite-strings -Wclaclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declaration -Wextra-tokens -pipe -Werror -c conftest.c
check程序是:
/ * begin * /
1:#includeruby.h
2:
3:int main(){return 0; }
/ * end * /

clang -I〜/ .rubies / ruby​​-2.3.1 / include / ruby​​-2.3.0 / x86_64-darwin16 -I〜/ .rubies /ruby-2.3.1/include/ruby-2.3.0/ruby/backward -I〜/ .rubies / ruby​​-2.3.1 / include / ruby​​-2.3.0 -I。 -I / usr / local / opt / openssl / include -I / usr / local / opt / readline / include -I / usr / local / opt / libyaml / include -I / usr / local / opt / gdbm / include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno -unused-parameter -Wno-括号-Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer -with -Wwrite-strings -Wclaclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declaration -Wextra-tokens -pipe -Wno-error = unused-command -line-argument-hard-error-in-future -Werror -c conftest.c
错误:未知的警告选项'-Werror = unused-command-line-argument-hard-error-in-future';你的意思是'-Werror = unused-command-line-argument'?[-Werror,-Wunknown-warning-option]
检查程序是:
/ * begin * /
1: #includeruby.h
2:
3:int main(){return 0;}
/ * end * /

have_header:检查iconv 。H... - - - - - - - - - --- yes

clang -E -I〜/ .rubies / ruby​​-2.3.1 / include / ruby​​-2.3.0 / x86_64 -darwin16 -I〜/ .rubies / ruby​​-2.3 .1 / include / ruby​​-2.3.0 / ruby​​ / backward -I〜/ .rubies / ruby​​-2.3.1 / include / ruby​​-2.3.0 -I。 -I / usr / local / opt / openssl / include -I / usr / local / opt / readline / include -I / usr / local / opt / libyaml / include -I / usr / local / opt / gdbm / include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno -unused-parameter -Wno-brackheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer -Wunused-variable -Wpointer -with -Wwrite-strings -Wclaclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -pipe conftest.c -o conftest.i
check程序是:
/ * begin * /
1:#includeruby.h
2:
3:#include< iconv.h> ;
/ * end * /

--------------------

have_library:检查gzdopen()in -lz ... -------------------- yes

clang -o conftest -I〜/ .rubies / ruby-2.3.1 / include / ruby​​-2.3.0 / x86_64-darwin16 -I〜/ .rubies / ruby​​-2.3.1 / include / ruby​​-2.3.0 / ruby​​ / backward -I〜/ .rubies / ruby​​- 2.3.1 / include / ruby​​-2.3.0 -I。 -I / usr / local / opt / openssl / include -I / usr / local / opt / readline / include -I / usr / local / opt / libyaml / include -I / usr / local / opt / gdbm / include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno -unused-parameter -Wno-括号-Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer -arith -Wwrite-strings -Wclaclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declaration -Wextra-tokens -pipe conftest.c -L。 -L〜/ .rubies / ruby​​-2.3.1 / lib -L ​​/ usr / local / opt / openssl / lib -L ​​/ usr / local / opt / readline / lib -L ​​/ usr / local / opt / libyaml / lib -L / usr / local / opt / gdbm / lib -L。 -fstack-protector -L / usr / local / opt / openssl / lib -L ​​/ usr / local / opt / readline / lib -L ​​/ usr / local / opt / libyaml / lib -L ​​/ usr / local / opt / gdbm / lib -lruby-static-framework CoreFoundation -lz -lpthread -ldl -lobjc
检查的程序是:
/ * begin * /
1:#includeruby.h
2:
3:#include< zlib.h>
4:
5:/ * top * /
6:extern int t(void);
7:int main(int argc,char ** argv)
8:{
9:if(argc> 1000000){
10:printf(%p,& amp ; t);
11:}
12:
13:return 0;
14:}
15:int t(void){void p)()); p =(void((*)()))gzdopen; return!p;}
/ * end * /

-------- ------------

have_iconv?:使用--with-opt- *标志检查iconv ------------ --------是

clang -o conftest -I〜/ .rubies / ruby​​-2.3.1 / include / ruby​​-2.3.0 / x86_64 -darwin16 -I〜/ .rubies / ruby​​-2.3.1 / include / ruby​​-2.3.0 / ruby​​ / backward -I〜/ .rubies / ruby​​-2.3.1 / include / ruby​​-2.3.0 -I。 -I / usr / local / opt / openssl / include -I / usr / local / opt / readline / include -I / usr / local / opt / libyaml / include -I / usr / local / opt / gdbm / include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno -unused-parameter -Wno-括号-Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer -arith -Wwrite-strings -Wclaclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declaration -Wextra-tokens -pipe conftest.c -L。 -L〜/ .rubies / ruby​​-2.3.1 / lib -L ​​/ usr / local / opt / openssl / lib -L ​​/ usr / local / opt / readline / lib -L ​​/ usr / local / opt / libyaml / lib -L / usr / local / opt / gdbm / lib -L。 -fstack-protector -L / usr / local / opt / openssl / lib -L ​​/ usr / local / opt / readline / lib -L ​​/ usr / local / opt / libyaml / lib -L ​​/ usr / local / opt / gdbm / lib -lruby-static-framework CoreFoundation -lpthread -ldl -lobjc
体系结构x86_64的未定义符号:
_iconv,引用自:
_main in conftest-d46614.o
_iconv_open,引用来自:
_main在conftest-d46614.o中
ld:架构x86_64未找到符号
clang:错误:linker命令失败,退出代码1 (使用-v来查看调用)
checked程序是:
/ * begin * /
1:#includeruby.h
2:
3: #include< stdlib.h>
4:#include< iconv.h>
5:
6:int main(void)
7:{
8:iconv_t cd = iconv_open(,);
9:iconv(cd,NULL,NULL,NULL,NULL);
10:return EXIT_SUCCESS;
11:}
/ * end * /

clang -o conftest -I〜/ .rubies / ruby​​-2.3.1 / include / ruby​​-2.3.0 / x86_64-darwin16 -I〜/。红宝石/红宝石2.3.1 /含ude / ruby​​-2.3.0 / ruby​​ / backward -I〜/ .rubies / ruby​​-2.3.1 / include / ruby​​-2.3.0 -I。 -I / usr / local / opt / openssl / include -I / usr / local / opt / readline / include -I / usr / local / opt / libyaml / include -I / usr / local / opt / gdbm / include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno -unused-parameter -Wno-括号-Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer -arith -Wwrite-strings -Wclaclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declaration -Wextra-tokens -pipe conftest.c -L。 -L〜/ .rubies / ruby​​-2.3.1 / lib -L ​​/ usr / local / opt / openssl / lib -L ​​/ usr / local / opt / readline / lib -L ​​/ usr / local / opt / libyaml / lib -L / usr / local / opt / gdbm / lib -L。 -fstack-protector -L / usr / local / opt / openssl / lib -L ​​/ usr / local / opt / readline / lib -L ​​/ usr / local / opt / libyaml / lib -L ​​/ usr / local / opt / gdbm / lib -lruby-static-framework CoreFoundation -liconv -lpthread -ldl -lobjc
检查的程序是:
/ * begin * /
1:#includeruby.h
2:
3:#include< stdlib.h>
4:#include< iconv.h>
5:
6:int main(void)
7:{
8:iconv_t cd = iconv_open(,);
9:iconv(cd,NULL,NULL,NULL,NULL);
10:return EXIT_SUCCESS;
11:}
/ * end * /

--------------------

gem_make.out:

 当前目录:〜/ .gem / ruby​​ / 2.3.1 / gems / nokogiri-1.6.8.1 / ext / nokogiri 
〜/ .rubies / ruby​​-2.3.1 / bin / ruby​​ -r ./ siteconf20161008-60071-tmqi2l.rb extconf.rb
忽略byebug-6.0.2,因为它的扩展没有被构建。试试:gem pristine byebug --version 6.0.2
忽略byebug-3.4.0,因为它的没有建立扩展。试试:ge m pristine byebug --version 3.4.0
检查C编译器是否接受... yes
检查C编译器是否接受-Wno-error = unused-command-line-argument-hard-error-未来... no
使用打包的库构建nokogiri。
使用mini_portile版本2.1.0
检查iconv.h ...是
在-lz中检查gzdopen()...是
使用--with检查iconv -opt- *标志...是
************************************* ***********************************
重要通知:

使用libxml2-2.9.4的打包版本构建Nokogiri。

Nokogiri团队将继续尽最大努力及时提供安全性
更新,但如果这是您的担忧并希望
使用系统库,放弃安装过程并
重新安装nokogiri,如下所示:

gem install nokogiri - --use-system-libraries
[--with-xml2-config = / path / to / xml2-config]
[--with-xslt-config = / path / to / xslt-config]

如果使用Bundler,请告诉它使用以下选项:

bundle config build.nokogiri --use-system-libraries
bundle install

但是请注意,nokogiri与任意
版本不完全兼容由OS /软件包供应商提供的libxml2。
********************************************** **************************
将libxml2-2.9.4.tar.gz解压缩到tmp / x86_64-apple-darwin16.1.0 /ports/libxml2/2.9.4 ... OK
为libxml2运行'configure'2.9.4 ... OK
为libxml2运行'compile'2.9.4 ...错误,查看'〜 /.gem/ruby/2.3.1/gems/nokogiri-1.6.8.1/ext/nokogiri/tmp/x86_64-apple-darwin16.1.0/ports/libxml2/2.9.4/compile.log'来查看发生了什么。最后一行是:
========================================== ==============================
unsigned short * in =(unsigned short *)inb;
^ ~~~~~~~~~~~~~~~~~~~~
encoding.c:815:27:warning:从'unsigned char *'转换为'unsigned short *'将所需的对齐从1增加到2 [-Wcast-align]
unsigned short * out =(unsigned short *)outb;
^ ~~~~~~~~~~~~~~~~~~~~生成警告。
CC error.lo
CC parserInternals.lo
CC parser.lo
CC tree.lo
CC hash.lo
CC list.lo
CC xmlIO.lo
xmlIO.c:1450:52:error:使用未声明的标识符'LZMA_OK'
ret =(__libxml2_xzclose((xzFile)context)== LZMA_OK)? 0:-1;
^
1产生的错误。
make [2]:*** [xmlIO.lo]错误1
make [1]:*** [all-recursive]错误1
make:*** [all]错误2
============================================ ============================
*** extconf.rb失败***
无法创建Makefile由于某种原因,可能缺少必要的
库和/或头文件。检查mkmf.log文件以获取更多详细信息。您可能
需要配置选项。

提供的配置选项:
--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 =〜/ .rubies / ruby​​-2.3.1 / bin / $(RUBY_BASE_NAME)
--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
〜/ .rubies / ruby​​-2.3.1 / lib / ruby​​ / gems / 2.3.0 / gems / mini_portile2-2.1.0 / lib / mini_portile2 / mini_portile.rb:366:在`block in execute'中:无法完成编译任务(RuntimeError)
from〜/ .rubies / ruby -2.3.1 / lib / ruby​​ / gems / 2.3.0 / gems / mini_portile2-2.1.0 / lib / mini_portile2 / mini_portile.rb:337:在〜/ .rubies / ruby​​-2.3中的`chdir'
.1 / lib / ruby​​ / gems / 2.3.0 / gems / mini_portile2-2.1.0 / lib / mini_portile2 / mini_portile.rb:337:在`execute'
from〜/ .rubies / ruby​​-2.3.1 /lib/ruby/gems/2.3.0/gems/mini_portile2-2.1.0/lib/mini_portile2/ mini_portile.rb:111:在`compile'
从〜/ .rubies / ruby​​-2.3.1 / lib / ruby​​ / gems / 2.3.0 / gems / mini_portile2-2.1.0 / lib / mini_portile2 / mini_portile。 rb:150:在`cook'
从extconf.rb:365:在`block(2个级别)in process_recipe'
从extconf.rb:258:在`block in chdir_for_build'
从extconf.rb:257:在`chdir'
从extconf.rb:257:在`chdir_for_build'
从extconf.rb:364:在`block in process_recipe'
from extconf。 rb:263:'tap'
from extconf.rb:263:'process_recipe'
from extconf.rb:556:in< main>'

To看看为什么这个扩展无法编译,请检查可以在这里找到的mkmf.log:

〜/ .gem / ruby​​ / 2.3.1 / extensions / x86_64-darwin-16 / 2.3.0 -static / nokogiri-1.6.8.1 / mkmf.log

extconf失败,退出代码1


解决方案

我试了@the_basterd的建议。这没有奏效,但参考很好 - 谢谢你,basterd。从该参考中得到的结果是:

brew install libxml2



bundle config build.nokogiri --use-system-libraries --with-xml2-include = / usr / local / opt / libxml2 / include / libxml2



参考: https://github.com/sparklemotion/nokogiri/issues / 1483



稍后在该裁判的帖子中表示,我上面张贴的内容强烈建议禁止Nokogiri。


brew unlink xz;捆绑安装; brew link xz 是首选



Building a new Rails app and getting a problem with nokogiri. Said to try gem install nokogiri -v '1.6.8.1' which fails with output below. I tried deleting Gemfile.lock and using the Gemfile from another app which has no problem—bundle install still fails. The original failure is bundle install which continues to work in other apps.

From console:

gem install nokogiri -v '1.6.8.1'
Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    current directory: ~/.gem/ruby/2.3.1/gems/nokogiri-1.6.8.1/ext/nokogiri
~/.rubies/ruby-2.3.1/bin/ruby -r ./siteconf20161008-60071-tmqi2l.rb extconf.rb
Ignoring byebug-6.0.2 because its extensions are not built.  Try: gem pristine byebug --version 6.0.2
Ignoring byebug-3.4.0 because its extensions are not built.  Try: gem pristine byebug --version 3.4.0
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
Using mini_portile version 2.1.0
checking for iconv.h... yes
checking for gzdopen() in -lz... yes
checking for iconv using --with-opt-* flags... yes
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxml2-2.9.4.

Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:

    gem install nokogiri -- --use-system-libraries
        [--with-xml2-config=/path/to/xml2-config]
        [--with-xslt-config=/path/to/xslt-config]

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************
Extracting libxml2-2.9.4.tar.gz into tmp/x86_64-apple-darwin16.1.0/ports/libxml2/2.9.4... OK
Running 'configure' for libxml2 2.9.4... OK
Running 'compile' for libxml2 2.9.4... ERROR, review '~/.gem/ruby/2.3.1/gems/nokogiri-1.6.8.1/ext/nokogiri/tmp/x86_64-apple-darwin16.1.0/ports/libxml2/2.9.4/compile.log' to see what happened. Last lines are:
========================================================================
    unsigned short* in = (unsigned short*) inb;
                         ^~~~~~~~~~~~~~~~~~~~~
encoding.c:815:27: warning: cast from 'unsigned char *' to 'unsigned short *' increases required alignment from 1 to 2 [-Wcast-align]
    unsigned short* out = (unsigned short*) outb;
                          ^~~~~~~~~~~~~~~~~~~~~~
4 warnings generated.
  CC       error.lo
  CC       parserInternals.lo
  CC       parser.lo
  CC       tree.lo
  CC       hash.lo
  CC       list.lo
  CC       xmlIO.lo
xmlIO.c:1450:52: error: use of undeclared identifier 'LZMA_OK'
    ret =  (__libxml2_xzclose((xzFile) context) == LZMA_OK ) ? 0 : -1;
                                                   ^
1 error generated.
make[2]: *** [xmlIO.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
========================================================================
*** 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=~/.rubies/ruby-2.3.1/bin/$(RUBY_BASE_NAME)
    --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
~/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:366:in `block in execute': Failed to complete compile task (RuntimeError)
    from ~/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:337:in `chdir'
    from ~/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:337:in `execute'
    from ~/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:111:in `compile'
    from ~/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:150:in `cook'
    from extconf.rb:365:in `block (2 levels) in process_recipe'
    from extconf.rb:258:in `block in chdir_for_build'
    from extconf.rb:257:in `chdir'
    from extconf.rb:257:in `chdir_for_build'
    from extconf.rb:364:in `block in process_recipe'
    from extconf.rb:263:in `tap'
    from extconf.rb:263:in `process_recipe'
    from extconf.rb:556:in `<main>'

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

  ~/.gem/ruby/2.3.1/extensions/x86_64-darwin-16/2.3.0-static/nokogiri-1.6.8.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in ~/.gem/ruby/2.3.1/gems/nokogiri-1.6.8.1 for inspection.
Results logged to ~/.gem/ruby/2.3.1/extensions/x86_64-darwin-16/2.3.0-static/nokogiri-1.6.8.1/gem_make.out

mkmf.log:

"clang -o conftest -I~/.rubies/ruby-2.3.1/include/ruby-2.3.0/x86_64-darwin16 -I~/.rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/backward -I~/.rubies/ruby-2.3.1/include/ruby-2.3.0 -I.  -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -pipe  conftest.c  -L. -L~/.rubies/ruby-2.3.1/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -L. -fstack-protector -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib     -lruby-static -framework CoreFoundation  -lpthread -ldl -lobjc  "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

"clang -I~/.rubies/ruby-2.3.1/include/ruby-2.3.0/x86_64-darwin16 -I~/.rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/backward -I~/.rubies/ruby-2.3.1/include/ruby-2.3.0 -I.  -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -pipe    -Werror -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main() {return 0;}
/* end */

"clang -I~/.rubies/ruby-2.3.1/include/ruby-2.3.0/x86_64-darwin16 -I~/.rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/backward -I~/.rubies/ruby-2.3.1/include/ruby-2.3.0 -I.  -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -pipe  -Wno-error=unused-command-line-argument-hard-error-in-future   -Werror -c conftest.c"
error: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future'; did you mean '-Werror=unused-command-line-argument'? [-Werror,-Wunknown-warning-option]
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main() {return 0;}
/* end */

have_header: checking for iconv.h... -------------------- yes

"clang -E -I~/.rubies/ruby-2.3.1/include/ruby-2.3.0/x86_64-darwin16 -I~/.rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/backward -I~/.rubies/ruby-2.3.1/include/ruby-2.3.0 -I.  -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -pipe   conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <iconv.h>
/* end */

--------------------

have_library: checking for gzdopen() in -lz... -------------------- yes

"clang -o conftest -I~/.rubies/ruby-2.3.1/include/ruby-2.3.0/x86_64-darwin16 -I~/.rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/backward -I~/.rubies/ruby-2.3.1/include/ruby-2.3.0 -I.  -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -pipe  conftest.c  -L. -L~/.rubies/ruby-2.3.1/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -L. -fstack-protector -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib     -lruby-static -framework CoreFoundation -lz  -lpthread -ldl -lobjc  "
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <zlib.h>
 4: 
 5: /*top*/
 6: extern int t(void);
 7: int main(int argc, char **argv)
 8: {
 9:   if (argc > 1000000) {
10:     printf("%p", &t);
11:   }
12: 
13:   return 0;
14: }
15: int t(void) { void ((*volatile p)()); p = (void ((*)()))gzdopen; return !p; }
/* end */

--------------------

have_iconv?: checking for iconv using --with-opt-* flags... -------------------- yes

"clang -o conftest -I~/.rubies/ruby-2.3.1/include/ruby-2.3.0/x86_64-darwin16 -I~/.rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/backward -I~/.rubies/ruby-2.3.1/include/ruby-2.3.0 -I.  -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -pipe  conftest.c  -L. -L~/.rubies/ruby-2.3.1/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -L. -fstack-protector -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib     -lruby-static -framework CoreFoundation  -lpthread -ldl -lobjc  "
Undefined symbols for architecture x86_64:
  "_iconv", referenced from:
      _main in conftest-d46614.o
  "_iconv_open", referenced from:
      _main in conftest-d46614.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <stdlib.h>
 4: #include <iconv.h>
 5: 
 6: int main(void)
 7: {
 8:     iconv_t cd = iconv_open("", "");
 9:     iconv(cd, NULL, NULL, NULL, NULL);
10:     return EXIT_SUCCESS;
11: }
/* end */

"clang -o conftest -I~/.rubies/ruby-2.3.1/include/ruby-2.3.0/x86_64-darwin16 -I~/.rubies/ruby-2.3.1/include/ruby-2.3.0/ruby/backward -I~/.rubies/ruby-2.3.1/include/ruby-2.3.0 -I.  -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -pipe  conftest.c  -L. -L~/.rubies/ruby-2.3.1/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -L. -fstack-protector -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib     -lruby-static -framework CoreFoundation -liconv -lpthread -ldl -lobjc  "
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <stdlib.h>
 4: #include <iconv.h>
 5: 
 6: int main(void)
 7: {
 8:     iconv_t cd = iconv_open("", "");
 9:     iconv(cd, NULL, NULL, NULL, NULL);
10:     return EXIT_SUCCESS;
11: }
/* end */

--------------------

gem_make.out:

current directory: ~/.gem/ruby/2.3.1/gems/nokogiri-1.6.8.1/ext/nokogiri
~/.rubies/ruby-2.3.1/bin/ruby -r ./siteconf20161008-60071-tmqi2l.rb extconf.rb
Ignoring byebug-6.0.2 because its extensions are not built.  Try: gem pristine byebug --version 6.0.2
Ignoring byebug-3.4.0 because its extensions are not built.  Try: gem pristine byebug --version 3.4.0
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
Using mini_portile version 2.1.0
checking for iconv.h... yes
checking for gzdopen() in -lz... yes
checking for iconv using --with-opt-* flags... yes
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxml2-2.9.4.

Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:

    gem install nokogiri -- --use-system-libraries
        [--with-xml2-config=/path/to/xml2-config]
        [--with-xslt-config=/path/to/xslt-config]

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************
Extracting libxml2-2.9.4.tar.gz into tmp/x86_64-apple-darwin16.1.0/ports/libxml2/2.9.4... OK
Running 'configure' for libxml2 2.9.4... OK
Running 'compile' for libxml2 2.9.4... ERROR, review '~/.gem/ruby/2.3.1/gems/nokogiri-1.6.8.1/ext/nokogiri/tmp/x86_64-apple-darwin16.1.0/ports/libxml2/2.9.4/compile.log' to see what happened. Last lines are:
========================================================================
    unsigned short* in = (unsigned short*) inb;
                         ^~~~~~~~~~~~~~~~~~~~~
encoding.c:815:27: warning: cast from 'unsigned char *' to 'unsigned short *' increases required alignment from 1 to 2 [-Wcast-align]
    unsigned short* out = (unsigned short*) outb;
                          ^~~~~~~~~~~~~~~~~~~~~~
4 warnings generated.
  CC       error.lo
  CC       parserInternals.lo
  CC       parser.lo
  CC       tree.lo
  CC       hash.lo
  CC       list.lo
  CC       xmlIO.lo
xmlIO.c:1450:52: error: use of undeclared identifier 'LZMA_OK'
    ret =  (__libxml2_xzclose((xzFile) context) == LZMA_OK ) ? 0 : -1;
                                                   ^
1 error generated.
make[2]: *** [xmlIO.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
========================================================================
*** 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=~/.rubies/ruby-2.3.1/bin/$(RUBY_BASE_NAME)
    --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
~/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:366:in `block in execute': Failed to complete compile task (RuntimeError)
    from ~/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:337:in `chdir'
    from ~/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:337:in `execute'
    from ~/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:111:in `compile'
    from ~/.rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:150:in `cook'
    from extconf.rb:365:in `block (2 levels) in process_recipe'
    from extconf.rb:258:in `block in chdir_for_build'
    from extconf.rb:257:in `chdir'
    from extconf.rb:257:in `chdir_for_build'
    from extconf.rb:364:in `block in process_recipe'
    from extconf.rb:263:in `tap'
    from extconf.rb:263:in `process_recipe'
    from extconf.rb:556:in `<main>'

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

  ~/.gem/ruby/2.3.1/extensions/x86_64-darwin-16/2.3.0-static/nokogiri-1.6.8.1/mkmf.log

extconf failed, exit code 1

解决方案

I tried @the_basterd's recommendation. That didn't work, but the reference was good—thank you the_basterd. What worked from that reference was:

brew install libxml2

bundle config build.nokogiri --use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2

Reference: https://github.com/sparklemotion/nokogiri/issues/1483

Later postings at that ref said that what I posted above "is strongly recommended against by the Nokogiri."

brew unlink xz; bundle install; brew link xz is preferred.

这篇关于gem install nokogiri -v'1.6.8.1'失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆