title: Bundle install fails due to nokogiri
body: <p>When I run <code>bundle install</code> in my Rails 4 application I get the following error:</p>
  
  <pre><code>An error occurred while installing nokogiri (1.6.1), and Bundler cannot continue.
  Make sure that `gem install nokogiri -v '1.6.1'` succeeds before bundling.
  </code></pre>
  
  <p>I'm using <code>rvm</code> and when I run <code>gem install nokogiri -v '1.6.1'</code> it works well. Moreover, when I run <code>gem list</code> I see nokogiri 1.6.1 installed, it's just that <code>bundle install</code> in my app does not work.</p>
  
  <p>By the way, it's happening only when I add the <code>impressionist</code> gem to my Gemfile, but I guess it's just a dependency.</p>
  
  <p>More info: I have followed, just in case, the instructions <a href="http://nokogiri.org/tutorials/installing_nokogiri.html" rel="nofollow">here</a>, and everything worked well.</p>
  
  <p>Any ideas? TIA</p>
  
  <hr>
  
  <p><strong>EDIT 1</strong>: The full error is:</p>
  
  <pre><code>Installing nokogiri (1.6.1) 
  Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
  
  /Users/sonxurxo/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb 
  /Users/sonxurxo/.rvm/rubies/ruby-1.9.3-p448/bin/ruby: invalid option -P  (-h will show valid options) (RuntimeError)
  
  Gem files will remain installed in /Users/sonxurxo/Documents/workspace/Smart Promo/RubyOnRails/vendor/bundle/gems/nokogiri-1.6.1 for inspection.
  Results logged to /Users/sonxurxo/Documents/workspace/Smart Promo/RubyOnRails/vendor/bundle/gems/nokogiri-1.6.1/ext/nokogiri/gem_make.out
  
  An error occurred while installing nokogiri (1.6.1), and Bundler cannot continue.
  Make sure that `gem install nokogiri -v '1.6.1'` succeeds before bundling.
  </code></pre>
  
  <hr>
  
  <p><strong>EDIT 2</strong>: I'm on Mac OS X Mavericks, with XCode and developer tools successfully installed</p>
  
  <hr>
  
  <p><strong>EDIT 3</strong>: My Gemfile:</p>
  
  <pre><code>source 'https://rubygems.org'
  
  # gem 'rails', '3.2.1'
  gem 'rails', '4.0.0'
  
  # Bundle edge Rails instead:
  # gem 'rails', :git =&gt; 'git://github.com/rails/rails.git'
  
  gem 'sqlite3'
  
  gem 'authlogic'
  
  gem 'acl9'
  
  gem 'recaptcha'
  
  gem 'omniauth-facebook'
  
  gem 'omniauth-twitter'
  
  gem "paperclip", "&gt;= 3.4.1"
  
  gem 'kaminari'
  
  gem 'activerecord-session_store'
  
  gem 'rpush'
  
  gem 'mysql2'
  
  gem 'twitter'
  
  gem 'gmaps4rails'
  
  gem 'gon'
  
  gem 'flexslider'
  
  gem 'jquery-ui-rails'
  
  gem "breadcrumbs_on_rails"
  
  gem "jquery-fileupload-rails"
  
  gem 'gettext_i18n_rails'
  
  gem 'gettext', '&gt;=3.0.2', :require =&gt; false, :group =&gt; :development
  
  gem 'thinking-sphinx'
  
  gem 'delayed_job_active_record'
  
  gem 'daemons'
  
  gem 'ts-delayed-delta', '~&gt; 2.0.0', :require =&gt; 'thinking_sphinx/deltas/delayed_delta'
  
  gem 'geocoder'
  
  gem 'i18n'
  
  gem 'globalize', '~&gt; 4.0.0'
  
  gem 'batch_translations'
  
  gem 'countries'
  gem 'country_select'
  
  # Gems used only for assets and not required
  # in production environments by default.
  group :assets do
    gem 'sass-rails', '~&gt; 4.0.0'
    gem 'coffee-rails', '~&gt; 4.0.0'
  
    # See https://github.com/sstephenson/execjs#readme for more supported runtimes
    # gem 'therubyracer'
  
    gem 'uglifier', '&gt;= 1.0.3'
  
    gem 'jquery-datatables-rails', github: 'rweng/jquery-datatables-rails'
  end
  
  gem 'jquery-rails'
  
  gem 'impressionist'
  </code></pre>
  
  <hr>
  
  <p><strong>EDIT 4</strong>: Output for <code>gem list nokogiri</code>:</p>
  
  <pre><code>*** LOCAL GEMS ***
  
  nokogiri (1.6.1, 1.5.9)
  </code></pre>