Reputation: 267160
Using irb the mail library worked fine, now I am creating my first ruby script.
I am getting the error:
testmail.rb:3:in `require': no such file to load -- mail (LoadError)
from testmail.rb:3
Below is the file testmail.rb:
#!/usr/bin/env ruby
require 'mail'
if __FILE__ == $0
Mail.defaults do
retriever_method :pop3, { :address => "mail.blah.com",
:port => 995,
:user_name => '[email protected]',
:password => 'asdfasdf',
:enable_ssl => false }
end
emails = Mail.all
end
Upvotes: 0
Views: 544
Reputation: 287690
You need to require rubygems before requiring any gem:
require "rubygems"
require "mail"
should work.
Upvotes: 3
Reputation: 46965
In irb execute puts$:
and at the command line execute ruby -e "puts $:"
You should see which gem path you are missing.
Upvotes: 0
Reputation: 369556
How did you install the mail
library? Which version of Ruby are you using? Which package did you use to install Ruby?
If you installed mail
via RubyGems, for example, and you are using Ruby 1.8, then you have to make sure that the RubyGems library is loaded before you load any Gems. Or more precisely, your administrator should have your environment set up in such a way that RubyGems gets loaded for you.
Upvotes: 0