blahedo
blahedo

Reputation: 834

bundle wants to install an old version of a gem---how do I find out why?

I am trying to rebuild a rails app that once worked (last checked in December or so) but during some system upgrade stopped working. When I run bundle install, most gems seem fine, but then it tries to install json 1.8.0 and fails.

I gather from hunting around online that json 1.8.0 is not compatible with ruby 2.2.0, so I tried installing newer versions—which build and install just fine. But when I re-run bundle install it tries once again to build json 1.8.0, and fails. My current problem is, I am totally stuck as far as finding why it even wants to install json 1.8.0; it is not itself listed in my Gemfile, and when I have manually run sudo gem install XXX for each of the gems in my Gemfile, the installation runs just fine. So I can't figure out what it has that has json 1.8.0 as a dependency, even!

I can run gem dependency json -R and get a list of what is successfully installed that depends on the json versions I do have, but of course it only lists gems that depend on versions >= or ~> some version, which are happy with the later versions.

I assume that I have to edit a gemfile, somewhere, to tell it not to use json 1.8.0 and to use '~> 1.8.0' instead, or something like that. Anyone have any idea where I should be looking for that?

Here are the gems I have listed in my Gemfile:

gem 'isbn_validation'
gem 'rails', '4.0.0'
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails', '~> 3.1.3'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
gem 'sdoc', require: false
gem 'devise', '~> 3.2.4'
gem 'cancan', '~> 1.6.10'
gem 'activerecord-session_store'
gem 'paperclip', '~> 4.2.0'

The output from gem dependency json -R:

Gem json-1.8.1
  Used by
    activesupport-4.2.3 (json (>= 1.7.7, ~> 1.7))
    loofah-2.0.3 (json (>= 0, development))
    sprockets-2.12.4 (json (>= 0, development))
    uglifier-2.7.1 (json (>= 1.8.0))

Gem json-1.8.2
  permutation (>= 0, development)
  sdoc (~> 0.3.16, development)
  Used by
    activesupport-4.2.3 (json (>= 1.7.7, ~> 1.7))
    loofah-2.0.3 (json (>= 0, development))
    sprockets-2.12.4 (json (>= 0, development))
    uglifier-2.7.1 (json (>= 1.8.0))

Gem json-1.8.3
  permutation (>= 0, development)
  sdoc (~> 0.3.16, development)
  Used by
    activesupport-4.2.3 (json (>= 1.7.7, ~> 1.7))
    loofah-2.0.3 (json (>= 0, development))
    sprockets-2.12.4 (json (>= 0, development))
    uglifier-2.7.1 (json (>= 1.8.0))

Here is a slightly abridged version of the output from bundle install:

Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 10.3.2
Using i18n 0.6.4
Using minitest 4.7.5
Using multi_json 1.7.7
Using atomic 1.1.10
[... omitting many ...]
Using isbn_validation 1.1.1
Using jbuilder 1.4.2
Using jquery-rails 3.1.3 (was 3.0.2)
Installing json 1.8.0 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.


    /usr/bin/ruby -r ./siteconf20150822-13426-pdmmtu.rb extconf.rb
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling generator.c
In file included from /usr/include/stdio.h:27:0,
                 from /usr/include/ruby-2.2.0/ruby/defines.h:26,
                 from /usr/include/ruby-2.2.0/ruby/ruby.h:29,
                 from /usr/include/ruby-2.2.0/ruby.h:33,
                 from ../fbuffer/fbuffer.h:5,
                 from generator.c:1:
/usr/include/features.h:328:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
 #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
    ^
In file included from generator.c:1:0:
../fbuffer/fbuffer.h: In function ‘fbuffer_to_s’:
../fbuffer/fbuffer.h:175:47: error: macro "rb_str_new" requires 2 arguments, but only 1 given
     VALUE result = rb_str_new(FBUFFER_PAIR(fb));
                                               ^
../fbuffer/fbuffer.h:175:20: warning: initialization makes integer from pointer without a cast [-Wint-conversion]
     VALUE result = rb_str_new(FBUFFER_PAIR(fb));
                    ^
Makefile:237: recipe for target 'generator.o' failed
make: *** [generator.o] Error 1

make failed, exit code 2

Gem files will remain installed in /tmp/bundler20150822-13426-vxbo1gjson-1.8.0/gems/json-1.8.0 for inspection.
Results logged to /tmp/bundler20150822-13426-vxbo1gjson-1.8.0/extensions/x86_64-linux/2.2.0/json-1.8.0/gem_make.out
An error occurred while installing json (1.8.0), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.0'` succeeds before bundling.

I'm on a Linux system; ruby -v is ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux], bundle -v is Bundler version 1.10.6.

Upvotes: 0

Views: 2502

Answers (1)

trvrfrd
trvrfrd

Reputation: 510

Your Gemfile.lock is what bundler actually checks when running bundle install, at least after the first time you've run bundler for a given project (see this StackOverflow post). Check that file and see if anything looks amiss. You could also try deleting it and re-running bundle install, or just run bundle update to install the latest versions of all your gems if you're not concerned about specific versions.

Upvotes: 1

Related Questions