Search code examples
rubyrubygemssinatra

Ruby 'require bunny' triggers what looks like a circular require


This case has me stumped. I am writing a pretty simple Sinatra app which is causing what looks like a circular require issue specifically with require "bunny". Here is some evidence which by the way is after lots of trials, moving code around, commenting out and so on:

As you can see I put a break point just before the require statement:

rake test
[MAINAPP Starting! Rack: test]
/Users/pitosalas/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sqlite3-1.3.12/lib/sqlite3/pragmas.rb:301: warning: method redefined; discarding old integrity_check
/Users/pitosalas/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sqlite3-1.3.12/lib/sqlite3/pragmas.rb:107: warning: previous definition of integrity_check was here

[1, 10] in /Volumes/MonsterHD/mydev/nanotwitter/services/nt_service.rb
    1: require 'byebug'
    2: require_relative "../services/service_dispatch"
    3:
    4: byebug
=>  5: require 'bunny'
    6:
    7: class NtService
    8:   def initialize
    9:     @requests = 0
   10:     @running = false

Now I verify that the Bunny class is not yet defined:

(byebug) Bunny
*** NameError Exception: uninitialized constant Bunny

nil
(byebug) next

Now I step over the 'require' and all hell breaks loose. A very long and apparently repetitive stack trace that includes errors referring to circular requires. Here are all the details: https://gist.github.com/pitosalas/de54212ddeac66328c02d64156845c8c

What can I try next?


Solution

  • try like this

    gem install bunny
    

    I think this will solve your problem.

    or upgrade your ruby version

    require "bunny"