gmail 和 parse_resource gems 之间的 Ruby 自动加载冲突 [英] Ruby autoload conflicts between gmail and parse_resource gems

查看:18
本文介绍了gmail 和 parse_resource gems 之间的 Ruby 自动加载冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早些时候,我问过gmail gem 中的自动加载无法找到它想要加载的文件.在构建一个最小的脚本时,我发现 gmail gem 加载了它的文件,而我没有包含 parse_resource gem.

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.

gmail gem 可让您从 Gmail 访问您的电子邮件、标签和收件箱.parse_resource gem 包装了 parse.com api.

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.

如果我在 gmail gem 之前包含 parse_resource gem ,ruby 会抛出 LoadError.

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.

require 'rubygems'
require 'parse_resource' 
require 'gmail'

Gmail.new('yourEmail@gmail.com', 'password')

工作正常

require 'rubygems'
#require 'parse_resource'
require 'gmail'

Gmail.new('yourEmail@gmail.com', 'password')

自动加载错误

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': 没有要加载的文件 -- gmail/client (LoadError)来自 emailError.rb:6

如何在我的程序中同时包含 parse_resource 和 gmail gem?

How do I include both the parse_resource and gmail gems into my programs?

-尼克

推荐答案

我已经用 bundler 安装了 gems.

I had installed the gems with bundler.

为了解决加载两个库的问题,我使用 gem 命令安装了 gem:sudo gem 安装 gmail parse_resource

To fix the issue with loading both libraries, I installed the gems with the gem command: sudo gem install gmail parse_resource

完成此操作后,我能够以任何顺序请求这些库,并且可以毫无问题地连接到 gmail 并进行解析.

With this done, I was able to require the libraries in any order, and to connect to gmail and parse without issue.

-尼克

这篇关于gmail 和 parse_resource gems 之间的 Ruby 自动加载冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆