我正在使用Mac OS X Mountain Lion(10.8.3)。
我正在关注railstutorial.org教程。在第3章中,它们在gemfile中包含"gem 'rspec-rails', '2.11.0'"
。从那时起,我无法让bundle update
在我的应用程序中工作,因为它正在尝试安装Nokogiri,这不起作用,但我不明白为什么。
这是我运行bundle update
时在控制台中发生的事情:
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.0.4)
Using i18n (0.6.1)
Using multi_json (1.7.2)
Using activesupport (3.2.13)
Using builder (3.0.4)
Using activemodel (3.2.13)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.5)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.1)
Using tilt (1.3.6)
Using sprockets (2.2.2)
Using actionpack (3.2.13)
Using mime-types (1.22)
Using polyglot (0.3.3)
Using treetop (1.4.12)
Using mail (2.5.3)
Using actionmailer (3.2.13)
Using arel (3.0.2)
Using tzinfo (0.3.37)
Using activerecord (3.2.13)
Using activeresource (3.2.13)
> Using bundler (1.3.5)
> Installing nokogiri (1.5.9)
> Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb
>checking for libxml/parser.h... yes
> checking for libxslt/xslt.h... yes
>checking for libexslt/exslt.h... yes
>checking for iconv_open() in iconv.h... no
>checking for iconv_open() in -liconv... no
>checking for iconv_open() in -liconv... yes
>checking for xmlParseDoc() in -lxml2... yes
>checking for xsltParseStylesheetDoc() in -lxslt... yes
>checking for exsltFuncRegister() in -lexslt... yes
>checking for xmlHasFeature()... yes
>checking for xmlFirstElementChild()... yes
>checking for xmlRelaxNGSetParserStructuredErrors()... yes
>checking for xmlRelaxNGSetParserStructuredErrors()... yes
>checking for xmlRelaxNGSetValidStructuredErrors()... yes
>checking for xmlSchemaSetValidStructuredErrors()... yes
>checking for xmlSchemaSetParserStructuredErrors()... yes
>creating Makefile
make
compiling html_document.c
compiling html_element_description.c
html_element_description.c: In function ‘get_description’:
html_element_description.c:249: warning: cast discards qualifiers from pointer target type
compiling html_entity_lookup.c
compiling html_sax_parser_context.c
compiling html_sax_push_parser.c
compiling nokogiri.c
compiling xml_attr.c
compiling xml_attribute_decl.c
compiling xml_cdata.c
compiling xml_comment.c
compiling xml_document.c
xml_document.c: In function ‘set_encoding’:
xml_document.c:159: warning: cast discards qualifiers from pointer target type
xml_document.c: In function ‘canonicalize’:
xml_document.c:505: warning: cast discards qualifiers from pointer target type
xml_document.c: In function ‘Nokogiri_wrap_xml_document’:
xml_document.c:569: warning: passing argument 1 of ‘st_init_numtable_with_size’ with
different width due to prototype
compiling xml_document_fragment.c
compiling xml_dtd.c
compiling xml_element_content.c
compiling xml_element_decl.c
compiling xml_encoding_handler.c
compiling xml_entity_decl.c
compiling xml_entity_reference.c
compiling xml_io.c
xml_io.c: In function ‘io_read_callback’:
xml_io.c:20: warning: passing argument 4 of ‘rb_rescue’ with different width due to
prototype
xml_io.c: In function ‘io_write_callback’:
xml_io.c:45: warning: passing argument 4 of ‘rb_rescue’ with different width due to prototype
compiling xml_libxml2_hacks.c
compiling xml_namespace.c
compiling xml_node.c
compiling xml_node_set.c
xml_node_set.c: In function ‘dealloc_namespace’:
xml_node_set.c:9: warning: cast discards qualifiers from pointer target type
xml_node_set.c:11: warning: cast discards qualifiers from pointer target type
xml_node_set.c: In function ‘deallocate’:
xml_node_set.c:52: warning: passing argument 3 of ‘st_foreach’ with different width due to
prototype
compiling xml_processing_instruction.c
compiling xml_reader.c
compiling xml_relax_ng.c
compiling xml_sax_parser.c
xml_sax_parser.c: In function ‘start_element’:
xml_sax_parser.c:69: warning: passing argument 1 of ‘rb_ary_new3’ with different width due to prototype
compiling xml_sax_parser_context.c
compiling xml_sax_push_parser.c
compiling xml_schema.c
compiling xml_syntax_error.c
compiling xml_text.c
compiling xml_xpath_context.c
compiling xslt_stylesheet.c
xslt_stylesheet.c: In function ‘parse_stylesheet_doc’:
xslt_stylesheet.c:72: warning: passing argument 2 of ‘rb_str_new’ with different width due to prototype
xslt_stylesheet.c: In function ‘transform’:
xslt_stylesheet.c:166: warning: passing argument 2 of ‘rb_str_new’ with different width due to prototype
linking shared-object nokogiri/nokogiri.bundle
ld: warning: directory not found for option '-L/opt/local/lib'
ld: in /usr/local/lib/libz.1.dylib, file was built for unsupported file format which is not the architecture being linked (x86_64) for architecture x86_64
collect2: ld returned 1 exit status
make: *** [nokogiri.bundle] Error 1
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p392/gems/nokogiri-1.5.9 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p392/gems/nokogiri-1.5.9/ext/nokogiri/gem_make.out
>An error occurred while installing nokogiri (1.5.9), and Bundler cannot
>continue.
>Make sure that `gem install nokogiri -v '1.5.9'` succeeds before bundling.
这是gem_make.out文件:
/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
checking for iconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetDoc() in -lxslt... yes
checking for exsltFuncRegister() in -lexslt... yes
checking for xmlHasFeature()... yes
checking for xmlFirstElementChild()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetValidStructuredErrors()... yes
checking for xmlSchemaSetValidStructuredErrors()... yes
checking for xmlSchemaSetParserStructuredErrors()... yes
creating Makefile
make
compiling html_document.c
compiling html_element_description.c
html_element_description.c: In function ‘get_description’:
html_element_description.c:249: warning: cast discards qualifiers from pointer target type
compiling html_entity_lookup.c
compiling html_sax_parser_context.c
compiling html_sax_push_parser.c
compiling nokogiri.c
compiling xml_attr.c
compiling xml_attribute_decl.c
compiling xml_cdata.c
compiling xml_comment.c
compiling xml_document.c
xml_document.c: In function ‘set_encoding’:
xml_document.c:159: warning: cast discards qualifiers from pointer target type
xml_document.c: In function ‘canonicalize’:
xml_document.c:505: warning: cast discards qualifiers from pointer target type
xml_document.c: In function ‘Nokogiri_wrap_xml_document’:
xml_document.c:569: warning: passing argument 1 of ‘st_init_numtable_with_size’ with different width due to prototype
compiling xml_document_fragment.c
compiling xml_dtd.c
compiling xml_element_content.c
compiling xml_element_decl.c
compiling xml_encoding_handler.c
compiling xml_entity_decl.c
compiling xml_entity_reference.c
compiling xml_io.c
xml_io.c: In function ‘io_read_callback’:
xml_io.c:20: warning: passing argument 4 of ‘rb_rescue’ with different width due to prototype
xml_io.c: In function ‘io_write_callback’:
xml_io.c:45: warning: passing argument 4 of ‘rb_rescue’ with different width due to prototype
compiling xml_libxml2_hacks.c
compiling xml_namespace.c
compiling xml_node.c
compiling xml_node_set.c
xml_node_set.c: In function ‘dealloc_namespace’:
xml_node_set.c:9: warning: cast discards qualifiers from pointer target type
xml_node_set.c:11: warning: cast discards qualifiers from pointer target type
xml_node_set.c: In function ‘deallocate’:
xml_node_set.c:52: warning: passing argument 3 of ‘st_foreach’ with different width due to prototype
compiling xml_processing_instruction.c
compiling xml_reader.c
compiling xml_relax_ng.c
compiling xml_sax_parser.c
xml_sax_parser.c: In function ‘start_element’:
xml_sax_parser.c:69: warning: passing argument 1 of ‘rb_ary_new3’ with different width due to prototype
compiling xml_sax_parser_context.c
compiling xml_sax_push_parser.c
compiling xml_schema.c
compiling xml_syntax_error.c
compiling xml_text.c
compiling xml_xpath_context.c
compiling xslt_stylesheet.c
xslt_stylesheet.c: In function ‘parse_stylesheet_doc’:
xslt_stylesheet.c:72: warning: passing argument 2 of ‘rb_str_new’ with different width due to prototype
xslt_stylesheet.c: In function ‘transform’:
xslt_stylesheet.c:166: warning: passing argument 2 of ‘rb_str_new’ with different width due to prototype
linking shared-object nokogiri/nokogiri.bundle
ld: warning: directory not found for option '-L/opt/local/lib'
ld: in /usr/local/lib/libz.1.dylib, file was built for unsupported file format which is not the architecture being linked (x86_64) for architecture x86_64
collect2: ld returned 1 exit status
make: *** [nokogiri.bundle] Error 1
在应用程序目录中运行bundle
在控制台中获取相同的消息:
"An error occurred while installing nokogiri (1.5.9), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.5.9'` succeeds before bundling."
我尝试gem install nokogiri
,在控制台中输出:
$ gem install nokogiri
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetDoc() in -lxslt... yes
checking for exsltFuncRegister() in -lexslt... yes
checking for xmlHasFeature()... yes
checking for xmlFirstElementChild()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetValidStructuredErrors()... yes
checking for xmlSchemaSetValidStructuredErrors()... yes
checking for xmlSchemaSetParserStructuredErrors()... yes
creating Makefile
make
compiling html_document.c
compiling html_element_description.c
html_element_description.c: In function ‘get_description’:
html_element_description.c:249: warning: cast discards qualifiers from pointer target type
compiling html_entity_lookup.c
compiling html_sax_parser_context.c
compiling html_sax_push_parser.c
compiling nokogiri.c
compiling xml_attr.c
compiling xml_attribute_decl.c
compiling xml_cdata.c
compiling xml_comment.c
compiling xml_document.c
xml_document.c: In function ‘set_encoding’:
xml_document.c:159: warning: cast discards qualifiers from pointer target type
xml_document.c: In function ‘canonicalize’:
xml_document.c:505: warning: cast discards qualifiers from pointer target type
xml_document.c: In function ‘Nokogiri_wrap_xml_document’:
xml_document.c:569: warning: passing argument 1 of ‘st_init_numtable_with_size’ with different width due to prototype
compiling xml_document_fragment.c
compiling xml_dtd.c
compiling xml_element_content.c
compiling xml_element_decl.c
compiling xml_encoding_handler.c
compiling xml_entity_decl.c
compiling xml_entity_reference.c
compiling xml_io.c
xml_io.c: In function ‘io_read_callback’:
xml_io.c:20: warning: passing argument 4 of ‘rb_rescue’ with different width due to prototype
xml_io.c: In function ‘io_write_callback’:
xml_io.c:45: warning: passing argument 4 of ‘rb_rescue’ with different width due to prototype
compiling xml_libxml2_hacks.c
compiling xml_namespace.c
compiling xml_node.c
compiling xml_node_set.c
xml_node_set.c: In function ‘dealloc_namespace’:
xml_node_set.c:9: warning: cast discards qualifiers from pointer target type
xml_node_set.c:11: warning: cast discards qualifiers from pointer target type
xml_node_set.c: In function ‘deallocate’:
xml_node_set.c:52: warning: passing argument 3 of ‘st_foreach’ with different width due to prototype
compiling xml_processing_instruction.c
compiling xml_reader.c
compiling xml_relax_ng.c
compiling xml_sax_parser.c
xml_sax_parser.c: In function ‘start_element’:
xml_sax_parser.c:69: warning: passing argument 1 of ‘rb_ary_new3’ with different width due to prototype
compiling xml_sax_parser_context.c
compiling xml_sax_push_parser.c
compiling xml_schema.c
compiling xml_syntax_error.c
compiling xml_text.c
compiling xml_xpath_context.c
compiling xslt_stylesheet.c
xslt_stylesheet.c: In function ‘parse_stylesheet_doc’:
xslt_stylesheet.c:72: warning: passing argument 2 of ‘rb_str_new’ with different width due to prototype
xslt_stylesheet.c: In function ‘transform’:
xslt_stylesheet.c:166: warning: passing argument 2 of ‘rb_str_new’ with different width due to prototype
linking shared-object nokogiri/nokogiri.bundle
ld: warning: directory not found for option '-L/opt/local/lib'
ld: in '/usr/local/lib/libz.1.dylib', file was built for unsupported file format ( 0xce 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 0 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): /usr/local/lib/libz.1.dylib for architecture x86_64
collect2: ld returned 1 exit status
make: *** [nokogiri.bundle] Error 1
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p392/gems/nokogiri-1.5.9 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p392/gems/nokogiri-1.5.9/ext/nokogiri/gem_make.out
答案 0 :(得分:0)
尝试只运行bundle
。可能存在由bundle update
引起的依赖性问题。
同时尝试gem install nokogiri
,并报告其输出。
好的,gem install
输出很有帮助。据我所知,您使用的是MacPorts,其中包括:
我会尝试安装自制程序,或重新安装MacPorts。
另外,从我所知的错误消息来看,主要问题归结为软件不兼容,无论是32位软件还是64位机器,反之亦然。也许你不小心下载了错误的版本。
答案 1 :(得分:0)
通过Homebrew和RVM进行全新安装似乎解决了这个问题。捆绑更新无误,nokogiri错误消失。
我使用RailsInstaller安装Ruby + Rails,之前用Rails Installer重新安装两次,同样的问题。使用自制软件后,问题消失了RVM。
使用 X代码4.6, RVM, 自制, Ruby 1.9.3p374, Rails 3.2.13