Rob Knight
Rob Knight

Reputation: 83

"Cannot load such file" error when deploying Rails app to Heroku

I'm using a gem for gmail in my Rails app. My Gemfile contains:

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):

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:

/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?

Upvotes: 1

Views: 1167

Answers (2)

Frederick Cheung
Frederick Cheung

Reputation: 84114

require is case sensitive if the underlying filesystem is case sensitive (which it is on linux, which is what underpins heroku)

Change to :require => 'gmail' instead of Gmail and you should be ok.

Upvotes: 3

Maxim
Maxim

Reputation: 9961

Just remove useless require option from your Gemfile because bundler can load classes inside of this gem without specify require option in your case.

gem 'gmail-api-ruby', '~> 0.0.10'

and run bundle install.

FYI: read section about require option here.

Upvotes: 0

Related Questions