Permalink
Browse files

Specify exact BSON version dependency

Since the mongo and bson gems are versioned together, it should follow
that mongo depends on a specific version of bson. Otherwise, client
libraries that require a specific version of mongo, expecting the same
version of bson to be installed may get a different version. This is
particularly painful when a client library specifies a dependency on
both mongo and bson_ext using the same version number, which may not be
the latest, and the dependency from the mongo gem will actually install
a different version of bson than bson_ext.
  • Loading branch information...
1 parent ad6edb0 commit 9e2f562892cf339275d2e7f835268c64723daf33 @mjackson mjackson committed May 17, 2011
Showing with 1 addition and 1 deletion.
  1. +1 −1 mongo.gemspec
View
@@ -30,5 +30,5 @@ Gem::Specification.new do |s|
s.email = 'mongodb-dev@googlegroups.com'
s.homepage = 'http://www.mongodb.org'
- s.add_dependency(%q<bson>, [">= #{Mongo::VERSION}"])
+ s.add_dependency('bson', Mongo::VERSION)
end

6 comments on commit 9e2f562

Contributor

batter replied Feb 27, 2012

This commit breaks the gemspec file so that it is in an invalid format for older versions of Rubygems. I believe to fix it, this line needs to be changed to:

s.add_dependency('bson', "~> #{Mongo::VERSION}")

or something to that effect. As far as I can tell there are problems when using just a plain version (which is why when you look around at other gems they all seem to use ~> on their dependency declarations in their .gemspec files. Just updated my project to use mongo, bson, & bson_ext versions 1.6.0 and then tried to push to Heroku and got the following error when running heroku run gem list:

WARNING:  #<ArgumentError: Illformed requirement ["#<Syck::DefaultKey:0x00000008be6b28> 1.6.0"]>
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|
  s.name = %q{mongo}
  s.version = "1.6.0"
 ...
  if s.respond_to? :specification_version then
    current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
    s.specification_version = 3

    if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
      s.add_runtime_dependency(%q<bson>, ["#<Syck::DefaultKey:0x00000008be6b28> 1.6.0"])
    else
      s.add_dependency(%q<bson>, ["#<Syck::DefaultKey:0x00000008be6b28> 1.6.0"])
    end
  else
    s.add_dependency(%q<bson>, ["#<Syck::DefaultKey:0x00000008be6b28> 1.6.0"])
  end
end
WARNING:  Invalid .gemspec format in '/app/.bundle/gems/ruby/1.9.1/specifications/mongo-1.6.0.gemspec'

Heroku is running Rubygems 1.3.7. Here is a blog post written by Tenderlove where he discusses the source of the error and the fix.

Try looking at indirect's comments on this issue request on the bundler gem. He seems to have some good suggestions of what to look for in bundler as well as how to fix it.

This is causing me issues too. Is there a workaround?

Contributor

batter replied Feb 28, 2012

Downgrade to 1.5.2. Alternatively you could fork the gem and then edit the .gemspec file yourself and modify the line as I have suggested. Fairly certain that would work, although I'd prefer to see the authors fix this. I also sent a support request to Heroku asking if they could upgrade the Rubygems version on their environment.

Contributor

banker replied Feb 28, 2012

We're pushing a release today. I'll fix it.

Awesome -- thanks Kyle, let me know when you want me to test it out.

Contributor

batter replied Feb 28, 2012

Just made a pull request which would fix the issue. Did so before I saw the reply by @banker. Thank you for being attentive to this!

Please sign in to comment.