Ruby autoload conflicts between gmail and parse_resource gems

你说的曾经没有我的故事 提交于 2019-12-20 02:54:56

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!