Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-1061

Driver depends on access to URI but doesn't provide it

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.2.0
    • Affects Version/s: 2.1.2
    • Component/s: None
    • Environment:
      Mac OS 10.11.0
      Ruby version 2.2.3
      Mongo version 2.1.2

      When using the mongo driver by itself in IRB, creating a client with a URI raises the following error:

      2.2.3 :007 > db = Mongo::Client.new(ENV['MONGOLAB_URI'])
      NameError: uninitialized constant URI
      	from /Users/david/.rvm/gems/ruby-2.2.3/gems/mongo-2.1.2/lib/mongo/uri.rb:339:in `decode'
      	from /Users/david/.rvm/gems/ruby-2.2.3/gems/mongo-2.1.2/lib/mongo/uri.rb:293:in `parse_user!'
      	from /Users/david/.rvm/gems/ruby-2.2.3/gems/mongo-2.1.2/lib/mongo/uri.rb:259:in `parse_creds_hosts!'
      	from /Users/david/.rvm/gems/ruby-2.2.3/gems/mongo-2.1.2/lib/mongo/uri.rb:243:in `setup!'
      	from /Users/david/.rvm/gems/ruby-2.2.3/gems/mongo-2.1.2/lib/mongo/uri.rb:195:in `initialize'
      	from /Users/david/.rvm/gems/ruby-2.2.3/gems/mongo-2.1.2/lib/mongo/client.rb:340:in `new'
      	from /Users/david/.rvm/gems/ruby-2.2.3/gems/mongo-2.1.2/lib/mongo/client.rb:340:in `create_from_uri'
      	from /Users/david/.rvm/gems/ruby-2.2.3/gems/mongo-2.1.2/lib/mongo/client.rb:198:in `initialize'
      

      My loadpath:

      2.2.3 :003 > puts $LOAD_PATH
      /Users/david/.rvm/gems/ruby-2.2.3/gems/map_by_method-0.8.3/lib
      /Users/david/.rvm/gems/ruby-2.2.3/gems/bson-3.2.6/lib
      /Users/david/.rvm/gems/ruby-2.2.3/extensions/x86_64-darwin-15/2.2.0/bson-3.2.6
      /Users/david/.rvm/gems/ruby-2.2.3/gems/mongo-2.1.2/lib
      /Users/david/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0
      /Users/david/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/x86_64-darwin15
      /Users/david/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby
      /Users/david/.rvm/rubies/ruby-2.2.3/lib/ruby/vendor_ruby/2.2.0
      /Users/david/.rvm/rubies/ruby-2.2.3/lib/ruby/vendor_ruby/2.2.0/x86_64-darwin15
      /Users/david/.rvm/rubies/ruby-2.2.3/lib/ruby/vendor_ruby
      /Users/david/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0
      /Users/david/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/x86_64-darwin15
      

      This issue is resolved by including

      require 'net/http'

      before any calls to the mongo driver, but if an external package is required in a library, it should require it itself.

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            Xavdidtheshadow David Brownman [X]
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: