gmailgem / gmail

A Rubyesque interface to Gmail, with all the tools you'll need.
Other
397 stars 119 forks source link

weird require order dependence with awesome_print #132

Closed bootstraponline closed 9 years ago

bootstraponline commented 9 years ago

From @yebyen on January 15, 2015 16:8

For some reason I have to require 'ap' before I require 'gmail' — I think this order dependence is a bug of the gmail gem, but I don't even know where to start to look. My gemfile.lock does not even mention activesupport, so I'm double confused why I would get this type of error.

Gemfile:

source 'https://rubygems.org'
gem 'gmail', :git => 'git://github.com/nu7hatch/gmail'
gem 'awesome_print', :require => 'ap'

test.rb:

#!/usr/bin/env ruby
require 'gmail'
require 'ap'

bundle exec ./test.rb:

/home/kbarrett/.rvm/gems/ruby-2.2.0/gems/awesome_print-1.6.1/lib/awesome_print.rb:29:in `<top (required)>': undefined method `on_load' for ActiveSupport:Module (NoMethodError)
    from /home/kbarrett/.rvm/gems/ruby-2.2.0/gems/awesome_print-1.6.1/lib/ap.rb:10:in `require'
    from /home/kbarrett/.rvm/gems/ruby-2.2.0/gems/awesome_print-1.6.1/lib/ap.rb:10:in `<top (required)>'
    from ./test.rb:3:in `require'
    from ./test.rb:3:in `<main>'

If I switch the order of the require statements it's fine:

test.rb:

#!/usr/bin/env ruby
require 'ap'
require 'gmail'

(no crash)

Copied from original issue: nu7hatch/gmail#132

bootstraponline commented 9 years ago

From @johnnyshields on January 15, 2015 16:13

My guess is that Gmail is requiring a lib which defines ActiveSupport as a constant but doesn't actually load it.

In https://github.com/nu7hatch/gmail/blob/master/lib/gmail.rb you can see these requires:

require 'net/imap'
require 'net/smtp'
require 'mail'
require 'date'
require 'time'

Mail in particular looks suspect, see requires here: https://github.com/mikel/mail/blob/master/lib/mail.rb

So... to summarize, see if you get the same result with 'mail' gem instead of 'gmail', and if so, close this issue and file it with mail here: https://github.com/mikel/mail

bootstraponline commented 9 years ago

From @johnnyshields on January 15, 2015 16:15

FYI this may be related: https://github.com/mikel/mail/issues/574

bootstraponline commented 9 years ago

From @yebyen on January 15, 2015 17:28

Thanks! That's it exactly.