[英]“Cannot load such file” error when deploying Rails app to Heroku
I'm using a gem for gmail in my Rails app. 我在我的Rails应用程序中使用了一个用于gmail的gem 。 My Gemfile contains: 我的Gemfile包含:
gem 'gmail-api-ruby', :require => 'Gmail'
And in my controller, I initialize the gem with (using devise/omniauth to get the refresh_token
from Google): 在我的控制器中,我使用(使用devise / omniauth从Google获取refresh_token
)初始化gem:
Gmail.client_id = ENV['CLIENT_ID']
Gmail.client_secret = ENV['CLIENT_SECRET']
Gmail.refresh_token = current_user.refresh_token
This works fine in development, but when I deploy to Heroku, I get the following error: 这在开发中工作正常,但是当我部署到Heroku时,我收到以下错误:
/app/vendor/bundle/ruby/2.2.0/gems/bundler-1.7.12/lib/bundler/runtime.rb:76:in `require': cannot load such file -- Gmail (LoadError)
I cannot figure out why. 我无法弄清楚为什么。 Should I be requiring the gem somewhere else in my app? 我应该在我的应用程序中的其他地方要求宝石吗?
require
is case sensitive if the underlying filesystem is case sensitive (which it is on linux, which is what underpins heroku) 如果底层文件系统区分大小写(它在linux上,这是heroku的基础),则require
区分大小写
Change to :require => 'gmail'
instead of Gmail
and you should be ok. 更改为:require => 'gmail'
而不是Gmail
,你应该没问题。
Just remove useless require
option from your Gemfile
because bundler
can load classes inside of this gem without specify require
option in your case. 只需从您的Gemfile
删除无用的require
选项,因为bundler
可以在此gem中加载类,而不require
在您的情况下指定require
选项。
gem 'gmail-api-ruby', '~> 0.0.10'
and run bundle install
. 并运行bundle install
。
FYI: read section about require
option here . 仅供参考:请在此处阅读有关require
选项的部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.