سؤال

When I run bundle install in my Rails 4 application I get the following error:

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.

I'm using rvm and when I run gem install nokogiri -v '1.6.1' it works well. Moreover, when I run gem list I see nokogiri 1.6.1 installed, it's just that bundle install in my app does not work.

By the way, it's happening only when I add the impressionist gem to my Gemfile, but I guess it's just a dependency.

More info: I have followed, just in case, the instructions here, and everything worked well.

Any ideas? TIA


EDIT 1: The full error is:

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.

EDIT 2: I'm on Mac OS X Mavericks, with XCode and developer tools successfully installed


EDIT 3: My Gemfile:

source 'https://rubygems.org'

# gem 'rails', '3.2.1'
gem 'rails', '4.0.0'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'

gem 'authlogic'

gem 'acl9'

gem 'recaptcha'

gem 'omniauth-facebook'

gem 'omniauth-twitter'

gem "paperclip", ">= 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', '>=3.0.2', :require => false, :group => :development

gem 'thinking-sphinx'

gem 'delayed_job_active_record'

gem 'daemons'

gem 'ts-delayed-delta', '~> 2.0.0', :require => 'thinking_sphinx/deltas/delayed_delta'

gem 'geocoder'

gem 'i18n'

gem 'globalize', '~> 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', '~> 4.0.0'
  gem 'coffee-rails', '~> 4.0.0'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer'

  gem 'uglifier', '>= 1.0.3'

  gem 'jquery-datatables-rails', github: 'rweng/jquery-datatables-rails'
end

gem 'jquery-rails'

gem 'impressionist'

EDIT 4: Output for gem list nokogiri:

*** LOCAL GEMS ***

nokogiri (1.6.1, 1.5.9)
هل كانت مفيدة؟

المحلول

I think I solved this.

I say think because it seems to be related with a misconfiguration concerning rvm and bundler.

bundler was installing my gems in vendor/bundle, and not using those from the rvm gemset. What I did was to tell bundler to use those gems from rvm, and then, since nokogiri was already installed, it worked.

Thank everyone for your comments and answers.

نصائح أخرى

Impressionist has the following dependency:

s.add_dependency 'nokogiri', '~> 1.5'

Do you need the latest version of nokogiri or can you live with this version as well?

With 'bundle install --deployment' it won't work if you are below a directory with spaces in its name. Replacing the spaces with underscores fixed a similar problem for me. See https://github.com/bundler/bundler/issues/3020

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top