Nokogiri giving me some trouble after adding AWS-SDK gem - ruby-on-rails

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

Related

"rake db:migrate" results in "The bundle currently has pg locked at 0.18.4"

I generated this scaffold in Rails. Then I did a "rake db:migrate". Then I got:
[31mYou have requested:
pg >= 0
The bundle currently has pg locked at 0.18.4.
Try running `bundle update pg`[0m
[33mRun `bundle install` to install missing gems.[0m
Then I did "bundle update" and "bundle install" which resulted in:
Installing pg 0.18.4 with native extensions
C:/jruby-9.0.4.0/lib/ruby/stdlib/rubygems/ext/ext_conf_builder.rb:39: warning: Tempfile#unlink or delete called on open file; ignoring
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
C:/jruby-9.0.4.0/bin/jruby.exe -r ./siteconf20151205-6108-1bkqm97.rb >extconf.rb
NotImplementedError: C extensions are not supported
<top> at C:/jruby-9.0.4.0/lib/ruby/stdlib/mkmf.rb:1
require at org/jruby/RubyKernel.java:939
(root) at C:/jruby>9.0.4.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1
<top> at extconf.rb:2
extconf failed, exit code 1
Gem files will remain installed in C:/jruby- 9.0.4.0/lib/ruby/gems/shared/gems/pg-0.18.4 for inspection.
Results logged to C:/jruby- 9.0.4.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.2.0/pg- 0.18.4/gem_make.out
An error occurred while installing pg (0.18.4), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.4'` succeeds before bundling.
In my Gemfile, I tried making "gem 'pg'" plain, then "bundle install"ing, but still got the error message.
Here's my Gemfile:
source 'https://rubygems.org'
group :production do
gem 'rails_12factor'
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
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 'sdoc', '~> 0.4.0', group: :doc
gem 'tzinfo-data', platforms: [:mingw, :mswin]
gem 'coffee-script-source', '1.8.0'
Looks like you're on a Windows machine running jRuby. Try using one of the following gems instead of pg:
https://github.com/jruby/activerecord-jdbc-adapter
https://github.com/headius/jruby-pg
This answer might also be of help:
unable to install pg gem

How do I get json gem 1.7.7 to Update?

I'm trying to run a rails app on my Windows 8.1 computer, but I need json gem version 1.8.1. I currently have json 1.7.7. Bundle install returns an error and asks for me to make sure "gem install json -v 1.8.1" succeeds. Running that command returns
E:\rails_projects\bookit>gem install json -v 1.8.2
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
C:/Ruby200-x64/bin/ruby.exe -r ./siteconf20150212-3852-vjuo23.rb extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
generating generator-x64-mingw32.def
compiling generator.c
make: x86_64-w64-mingw32-gcc: Command not found
make: *** [generator.o] Error 127
make failed, exit code 2
Gem files will remain installed in C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/json-
1.8.2 for inspection.
Results logged to C:/Ruby200-x64/lib/ruby/gems/2.0.0/extensions/x64-mingw32/2.0.
0/json-1.8.2/gem_make.out
E:\rails_projects\bookit>
I added the DevKit path to my list of environment variables. I find it odd that I am having a problem with DevKit because green_shoes installs and works fine, and it requires DevKit. What am I missing?
Note:
I am using Ruby 2.0.0, 64-bit, as well as the corresponding DevKit as recommended by rubyinstaller.org
EDIT: Gemfile for my rails app
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.1.4'
gem 'bootstrap-sass', '2.3.2.0'
gem 'sprockets', '2.11.0'
gem 'bcrypt-ruby', '3.1.2'
gem 'will_paginate', '3.0.4'
gem 'bootstrap-will_paginate', '0.0.9'
gem 'barista'
gem 'jquery-rails'
group :development, :test do
gem 'sqlite3'
gem 'rspec-rails', '2.14.0'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
gem 'factory_girl_rails', '4.2.0'
end
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
https://github.com/rails/turbolinks
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
group :doc do
gem 'sdoc', '~> 0.4.0', require: false
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
This is your error:
make: x86_64-w64-mingw32-gcc: Command not found
--
The error is caused because the gcc/gc++ compiler is not found on your computer.
You should refer to this page for more information on this.
You should download this build kit, install it and then run the following:
set PATH=c:/path/to/your/mingw64/installation;%PATH%
Then perform the build again - it should work.

Unable to bundle install (nokogiri 1.5.2) old project, new computer

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.

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

Bundle install fails due to nokogiri

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

Resources