问题
Earlier, I asked about autoload in the gmail gem not being able to find the files it wanted to load. In building a minimal script, I found the gmail gem loaded it's files when I didn't include the parse_resource gem.
The gmail gem lets you access your emails, labels, and inboxes from gmail. The parse_resource gem wraps the parse.com api in an ActiveRecord pattern.
If I include the parse_resource gem before the gmail gem, ruby throws a LoadError.
These are the permutations of the minimal script I wrote, organized by error.
LoadError
require 'rubygems'
require 'parse_resource'
require 'gmail'
Gmail.new('yourEmail@gmail.com', 'password')
Works Fine
require 'rubygems'
#require 'parse_resource'
require 'gmail'
Gmail.new('yourEmail@gmail.com', 'password')
Autoload Error
require 'rubygems'
require 'gmail'
require 'parse_resource'
Gmail.new('yourEmail@gmail.com', 'password')
/Library/Ruby/Gems/1.8/gems/gmail-0.4.0/lib/gmail.rb:50:in 'new': no such file to load -- gmail/client (LoadError)
from emailError.rb:6
How do I include both the parse_resource and gmail gems into my programs?
-Nick
回答1:
I had installed the gems with bundler.
To fix the issue with loading both libraries, I installed the gems with the gem command:
sudo gem install gmail parse_resource
With this done, I was able to require the libraries in any order, and to connect to gmail and parse without issue.
-Nick
来源:https://stackoverflow.com/questions/12237941/ruby-autoload-conflicts-between-gmail-and-parse-resource-gems