Forum: Ruby on Rails NET::IMAP / Runner problems

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0d03b87fc119adbecf4fb5779f44a510?d=identicon&s=25 Joe Smith (stone1549)
on 2006-12-28 20:55
Hello,

I have a runner script that is meant to check a mailbox using imap and
insert them into the application.  The method I am using to do this was
taken directly off the rails wiki:

  require 'net/imap' # above the class, not within it


  def self.check_mail
    imap = Net::IMAP.new('localhost')
    imap.authenticate('LOGIN', 'username', 'password')
    imap.select('INBOX')
    imap.search(['ALL']).each do |message_id|
      msg = imap.fetch(message_id,'RFC822')[0].attr['RFC822']

      MailReader.receive(msg)
      #Mark message as deleted and it will be removed from storage when
user session closd
      imap.store(message_id, "+FLAGS", [:Deleted])
    end
  end

The following is the output I receive when I run the runner script:

/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/runner.rb:27:
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:123:in
`const_missing': uninitialized constant SSL (NameError)
        from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:133:in
`const_missing'
        from /usr/lib/ruby/1.8/net/imap.rb:204
        from
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
        from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require'
        from script/../config/../app/models/mailer.rb:1
        from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:140:in
`load'
        from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:56:in
`require_or_load'
        from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:30:in
`depend_on'
        from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:85:in
`require_dependency'
        from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:98:in
`const_missing'
        from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:in
`const_missing'
        from (eval):1
        from
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `eval'
        from
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/runner.rb:27
        from
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
        from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require'
        from script/runner:3


Any ideas?
0d03b87fc119adbecf4fb5779f44a510?d=identicon&s=25 Joe Smith (stone1549)
on 2006-12-28 21:14
I've narrowed it down to an issue with 'net/imap', if I comment out
everything but the require line the same errors occur.  Does net/imap
require OpenSSL be installed or something?
0d03b87fc119adbecf4fb5779f44a510?d=identicon&s=25 Joe Smith (stone1549)
on 2006-12-28 21:19
And another discovery...  it only happens in the Rails environment.  If
I type

"require 'net/imap'" into the rails console I get:

>> require 'net/imap'
NameError: uninitialized constant SSL
        from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:123:in
`const_missing'
        from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:133:in
`const_missing'
        from /usr/lib/ruby/1.8/net/imap.rb:204
        from
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
        from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require'
        from (irb):1


however when I type it into irb it get no error at all..
0d03b87fc119adbecf4fb5779f44a510?d=identicon&s=25 Joe Smith (stone1549)
on 2006-12-28 23:03
I commented out line 204 of /usr/lib/ruby/1.8/net/imap and it worked
fine afterwards.  I'm guessing that ubuntu doesn't have some package
installed by default that other distros do.... (like SendMail and
GCC....)

It will probably cause me more problems down the road, but at least for
now I can use net/imap.
This topic is locked and can not be replied to.