Having not touched my Rails application for around a year, I decided to try to get the application up and running but am stuck because what I believe to be a dependency somewhere in my Gemfile. I have included it at the bottom.
My issue is that I am running into the error:
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
extconf.rb:10:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
extconf.rb:10:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
extconf.rb:11:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
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... no
-----
libxml2 is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
An error occurred while installing nokogiri (1.5.2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.5.2'` succeeds before bundling.
However upon trying to install Nokogiri separately, I found that I am able to install -v 1.6.3.1 without error. I know that libxml2, libiconv, etc., are installed in my computer but am unsure if the versions match with what Nokogiri 1.5.2 is expecting. Also, I tried using the xcode-select --install approach but to no avail.
So my questions are:
How can I update my gemfile to use Nokogiri 1.6.3.1, which I am able to install. When I don't know which gem is using it as a dependecy, is there a way to look that up?
Without removing each gem one by one, is there a way to figure out/remove Nokogiri all together?
If there is no way to do #1 or #2, then how can I successfully install Nokogiri 1.5.2?
Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.2.8'
gem 'faker', '1.0.1'
gem 'will_paginate', '3.0.3'
gem 'sass-rails', '3.2.4'
gem 'coffee-rails', '3.2.2'
gem 'compass-rails'
gem 'compass-960-plugin'
gem 'uglifier', '1.2.3'
gem 'chosen-rails'
gem 'bbcoder'
gem 'sanitize'
gem 'devise'
gem 'possessive'
gem 'err_merchant', :git => "git://github.com/iindigo/err_merchant.git"
gem 'impressionist'
#gem 'kaminari'
#gem 'bcrypt-ruby', '3.0.1' to use rails has_secure_passwordv
group :development do
gem 'sqlite3', '1.3.5'
gem 'annotate', '2.5.0'
gem 'rails-erd'
gem 'rack-mini-profiler'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
end
gem 'jquery-rails'
gem 'rails_tokeninput', '1.6.1.rc1'
gem 'selectivizr-rails'
gem 'friendly_id'
gem 'haml'
gem 'browser'
group :test, :development do
gem 'rspec-rails', '2.8.1'
gem 'spork', '0.9.0'
end
group :test do
gem 'capybara', '1.1.2'
gem 'factory_girl_rails', '1.4.0'
end
group :production do
gem 'sqlite3', '1.3.5'
# gem 'therubyracer'
end
sudo apt-get install ruby-dev libxml2-dev libxslt-dev and then try running bundle install again.
I figured out that by doing the command bundle update "gemnamehere" it was possible to get a list of the dependencies of each gem in the case of failure to update.
This in turn allowed me to figure out which gems I needed to change in-order to get Nokogiri to update.
Related
I'm not able to install bcrypt
My environment - Mac Yosemite 10.10, Ruby - 1.9.3 p547, Rails - 3.2.15.
When I run bundle install i'm getting like this.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/mohit/.rvm/rubies/ruby-1.9.3-p547/bin/ruby extconf.rb
creating Makefile
make clean
make
compiling bcrypt_ext.c
make: *** [bcrypt_ext.o] Segmentation fault: 11
make failed, exit code 2
Gem files will remain installed in /Users/mohit/.rvm/gems/ruby-1.9.3-p547/gems/bcrypt-3.1.9 for inspection.
Results logged to /Users/mohit/.rvm/gems/ruby-1.9.3-p547/extensions/x86_64-darwin-13/1.9.1/bcrypt-3.1.9/gem_make.out
An error occurred while installing bcrypt (3.1.9), and Bundler cannot continue.
Make sure that `gem install bcrypt -v '3.1.9'` succeeds before bundling.
Like
Here is my Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.15'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
#gem 'devise'
gem 'jquery-rails'
gem "sorcery"
# To use ActiveModel has_secure_password
gem 'bcrypt-ruby'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
Here's what I found that corrected my problem when I encountered the same error:
xcode-select --install
bundle install
Of note, I'm also on Yosemite but Ruby 2.1.3, Rails 4.1.6.
I made changes in the gem file by replacing gem 'bcrypt' instead of gem 'bcrypt-ruby' and did bundle install and worked for me!!
Finally I figured it out by copying the exact word of the bcrypt from the rubygems.org, then made slight changes in name, and then I did bundle install and it worked.
I added the aws-sdk to my Gemfile as followed: gem 'aws-sdk', '~> 1.45.0'
and then proceeded to run bundle install in the terminal. However, the bundle did not work correctly and was not able to complete successfully.
command line prompt
Building nokogiri using system libraries.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/cyrusghazanfar/.rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb --use-system-libraries
Building nokogiri using system libraries.
libxml2 version 2.9.0 and later is not yet supported, but proceeding anyway.
checking for xmlParseDoc() in libxml/parser.h... yes
checking for xsltParseStylesheetDoc() in libxslt/xslt.h... yes
checking for exsltFuncRegister() in libexslt/exslt.h... 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 "DESTDIR=" clean
make "DESTDIR="
compiling html_document.c
make: /usr/bin/gcc-4.2: No such file or directory
make: *** [html_document.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/cyrusghazanfar/.rvm/gems/ruby-2.1.2/gems/nokogiri-1.6.2.1 for inspection.
Results logged to /Users/cyrusghazanfar/.rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.2.1/gem_make.out
An error occurred while installing nokogiri (1.6.2.1), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.6.2.1'` succeeds before bundling.
Gemfile
source 'https://rubygems.org'
gem 'rails', '4.1.1'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'bootstrap-sass'
gem 'devise', '~> 3.2.4'
gem 'paperclip', github: 'thoughtbot/paperclip'
gem 'aws-sdk', '~> 1.45.0'
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'spring', group: :development
Nokogiri is giving me some problem here and I can't figure out what exactly.
Could someone help?
The problem is that make can't find /usr/bin/gcc-4.2:
make: /usr/bin/gcc-4.2: No such file or directory
If you have Xcode and Command Line Tools installed, then gcc is in /usr/bin. To fix the issue with make, create a symlink for gcc-4.2 which points to gcc:
sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
I'm following the instruction on the Rails Tutorial Chapter 3. When running the command line bundle install --without production I'm getting:
Bundler could not find compatible versions for gem "sprockets-rails":
In snapshot (Gemfile.lock):
sprockets-rails (2.1.3)
In Gemfile:
sass-rails (= 4.0.1) ruby depends on
sprockets-rails (~> 2.0.0) ruby
Running bundle update will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
When running bundle update I'm getting:
An error occurred while installing nokogiri (1.6.2.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.2.1'` succeeds before bundling.
When I run gem install nokogiri -v '1.6.2.1' it complains:
Building native extensions. This could take a while... Building
nokogiri using packaged libraries. ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/yotamros/.rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb Building
nokogiri using packaged libraries. ----- libiconv is missing. please
visit nokogiri.org/tutorials/installing_nokogiri.html for help with
installing dependencies. ----- * extconf.rb failed *
This is my Gemfile:
source 'https://rubygems.org'
ruby '2.1.2'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.1.1'
group :development, :test do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.13.1'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
Any help would be much appreciated.
I found the solution that worked for me here (by Claudio Poli):
brew reinstall libiconv libxml2 libxslt
gem install nokogiri -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.14/
Try bumping sass-rails to '~> 4.0.3' in your Gemfile. You have it locked to a specific slightly out of date version. For what it's worth, a brand new Rails 4.1.1 project has these gems:
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'therubyracer', platforms: :ruby
gem 'jquery-rails'
gem 'turbolinks'
(I would have put this in a comment but I'm not that cool yet.)
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
I am receiving an error while bundle install my updates. Here is my gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
gem 'libv8'
gem 'therubyracer'
gem 'haml'
gem 'haml-rails'
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'compass-rails'
gem 'chosen-rails'
gem "bootstrap-wysihtml5-rails", "~> 0.3.1.10"
gem 'hpricot'
gem "rest-open-uri", "~> 1.0.0"
gem 'jquery-datatables-rails', github: 'rweng/jquery-datatables-rails'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer'
gem 'uglifier', '>= 1.0.3'
gem "commonjs", "~> 0.2.6"
gem "less", "~> 2.2.2"
gem "less-rails", "~> 2.2.6"
end
gem 'jquery-rails'
gem 'simple_form'
gem 'client_side_validations'
gem 'client_side_validations-simple_form'
# To use ActiveModel has_secure_password
gem 'bcrypt-ruby', '~> 3.0.0'
Here is an error i am getting after running bundle install command on production:
An error occured while installing therubyracer (0.11.0), and Bundler
cannot continue. Make sure that gem install therubyracer -v '0.11.0'
succeeds before bundling.
I did the following that worked for me:
I commented out therubyracer from my Gemfile
ran "bundle install"
installed the newest version of therubyracer using "gem install therubyracer" (at the time of writing this is 0.11.2)
I uncommented therubyracer to put it back in to my Gemfile
ran "bundle install" again and everything works
Including libv8 in the Gemfile seems to be a fix to that:
gem 'libv8', '~> 3.11.8.3'
via https://github.com/cowboyd/therubyracer/issues/215
I did a gem uninstall therubyracer & gem uninstall libv8, then remove libv8 from the gemfile and just use therubyracer, then run 'bundle install'
group :assets do
gem 'therubyracer'
end
If it still does not work, just try to intall NodeJS
probably, your libv8 version and therubyracer version are not matching.
So, either you can include proper libv8 version in the Gemfile, which is similar to the
jibiel's solution
gem 'libv8', '~> 3.11.8.3'
But, I would prefer to do these two steps, So, that you don't have to worry about finding proper version of libv8:
Gemfile
gem 'therubyracer'
terminal
gem uninstall libv8
bundle install
And, that is what I have done to solve my same problem