Bundle install fails due to nokogiri - ruby-on-rails

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

Related

Error parsing Gemfile when pushing to Heroku

I have an existing rails app in Heroku and I'm trying to push it there but it gives me this error everytime I try to push to Heroku
There was an error parsing your Gemfile, we cannot continue
remote: ! /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/vendor/ruby/heroku-18/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
remote: ! from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/vendor/ruby/heroku-18/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
remote: ! from /tmp/d20190617-88-bonyg7/bundler-2.0.1/bin/bundle:23:in `<main>'
From there, what I think stands out the most are:
There was an error parsing your Gemfile, we cannot continue
can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
My Gemfile.lock states that my app is bundled with 2.0.2
When I do gem list, bundler part gives me this bundler (default: 2.0.2, default: 1.17.2)
Any help is appreciated! Thanks!
EDIT:
Here is my Gemfile
source 'https://rubygems.org'
ruby '2.6.3'
gem 'bootsnap', require: false
gem 'devise'
gem 'jbuilder', '~> 2.0'
gem 'pg', '~> 0.21'
gem 'puma'
gem 'rails', '5.2.3'
gem 'redis'
gem 'autoprefixer-rails'
gem 'font-awesome-sass', '~> 5.6.1'
gem 'sassc-rails'
gem 'simple_form'
gem 'uglifier'
gem 'webpacker'
gem 'bundler'
gem 'material-sass', '4.1.1'
gem 'cloudinary'
gem 'carrierwave'
group :development do
gem 'web-console', '>= 3.3.0'
end
group :development, :test do
gem 'pry-byebug'
gem 'pry-rails'
gem 'listen', '~> 3.0.5'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'dotenv-rails'
end
The issue here is that Heroku is unable to use the bundle that you are requesting him to use. You can fix it with many solutions while you request Heroku to use a bundle they know (As I know, 2.0.2 does not work).
Opening your Gemfile.lock and at the end of the file replace
BUNDLED WITH
2.0.2
with
BUNDLED WITH
2.0.1
To fix the issue on the long term you can just gem uninstall bundler and then run gem install bundler -v 2.0.1

When I run bundle install i'm getting error with bcrypt gem

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.

Unable to install bundle

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.)

Getting error while installing therubyracer

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

Passenger says Bundler:GemNotFound error while the bundle install says it's there

i get Passenger error on shared hosting
Could not find i18n-0.6.0 in any of the sources (Bundler::GemNotFound)
but if i run "bundle install" it says everything is ok :(
and the contents of the Gemfile are:
source 'http://rubygems.org'
gem 'rake', '0.8.7'
gem 'tzinfo', '0.3.27'
gem 'mail', '2.2.16'
gem 'arel', '2.0.9'
gem 'rack', '1.2.2'
gem 'i18n', '0.6.0'
gem 'rails', '3.0.5'
gem 'mysql2'
gem 'paperclip'
gem 'devise'
gem 'jquery-rails'
gem 'acts-as-taggable-on'
gem "will_paginate", "~> 3.0.pre2"
gem 'tiny_mce'
gem "oa-oauth", :require => "omniauth/oauth"
gem "acts_as_list"
"bundle show i18n" gives
/usr/lib/ruby/gems/1.8/gems/i18n-0.6.0
is it the error in my app or error of the hosting? how do i solve it?
it was hosting service bug. here's their reply:
"Passenger and the shell are on two different servers. i18n was installed on
Passenger, however the version was not 0.6.0."
so as i suspected different gems were used for passenger than the ones bundler used

Resources