Bundler won't update because of nokogiri, already installed libxml2, what is the issue?-Collection of common programming errors

In Max OS X Mountain Lion (10.8.3): I’m following the railstutorial.org tutorial, and on chapter 3 we started to include "gem 'rspec-rails', '2.11.0'" in the gemfile. Since then I can’t seem to get ‘bundle update’ to work in my application because it’s trying to install nokogiri, which doesn’t like me…why?

This is what happens in console when I run

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.

This is the gem_make.out file:

/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

Update:

just running ‘bundle’ in the application directory gets the same message in console:

“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.”

Tried ‘gem install nokogiri’ – Outputs this in console:

'$ 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