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?
Ruby 2.2.0
Bundler: 1.8.5
Rails: 4.2.0
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.
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.
Related
I'm creating an azure wrapper for dragonfly gem and I've published it in rubygems. Now I'm loading it in the Gemfile of my rails app with:
gem 'dragonfly-azure_data_store',
git: 'https://github.com/meloncargo/dragonfly-azure_data_store.git',
branch: :master
and the gem loads, but as I'm changing it constantly, I've configured bundler to load directly from my path:
bundle config local.dragonfly-azure_data_store /home/alter/workspace/meloncargo/dragonfly-azure_data_store
and when I start the rails app, it throws:
/home/alter/.rvm/gems/ruby-2.4.2#productwatcher/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in
`require': cannot load such file -- dragonfly-azure_data_store
(LoadError)
I've tried setting the gem as a path, without the bundler config:
gem 'dragonfly-azure_data_store',
path: '/home/alter/workspace/meloncargo/dragonfly-azure_data_store'
But I receive the same error. Just for the record, my local gem has the same changes as in master and any change I made locally (example: adding puts 'foo' inside def initialize of the main class), is reflected when I started the rails app, but eventually the error is raised.
Any idea what could be the problem?
I've just realized the problem has to do with I'm using require_reloader gem .
I've created an issue to see what happens with it.
Using a relative path for the argument should work
gem 'dragonfly-azure_data_store', path: '../dragonfly-azure_data_store'
And in your ruby file:
require 'dragonfly'
require 'dragonfly/azure_data_store'
When I add
require 'soundcloud'
in Rails and start the server using
rails server
I get
...rb:9:in `require': cannot load such file -- soundcloud (LoadError)
the same yields
=> true
in IRB.
I installed Ruby, Rails, etc following http://installrails.com/.
Any ideas what could be causing this?
Why don't you use Bundler?
Add to Gemfile:
gem 'soundcloud'
then run
bundle install
in the root of your project and it all should work automatically.
I'm bewildered here. While I can run require "gmail" in irb and successfully load the Gmail gem, doing so in my rails console returns false. I made sure to include all the directories in $LOAD_PATH for irb in the $LOAD_PATH for my console, but still cannot get the gem to load in my console.
It may be that the gmail gem is conflicting with another gem that I have installed, but I don't know how to confirm this. It seems other people have had similar problems:
Why is autoload failing to load files for gems
Ruby autoload conflicts between gmail and parse_resource gems
Rails: Using ruby-gmail gem causes problems
I made sure to include 'gem "gmail"' in my Gemfile and run bundle install. Still no luck!
Stuck here, so would appreciate any help.
false doesn't mean that the gem is failing to load, it means that the gem is already loaded.
It the rails console could not find the gem you would get a LoadError. Here's an example of an app of mine that has gem 'haml' in the Gemfile.
1.9.2p320 :001 > require 'haml'
=> false
1.9.2p320 :002 > require 'foo'
LoadError: no such file to load -- foo
Another way to see this is to require 'gmail' a second time in your irb session.
You must add this line to your Gemfile:
gem 'gmail'
This is because the gems loaded by your application are restricted to just the ones specified inside the Gemfile, and their dependencies (and the dependencies of the dependencies, and so on).
I am using Ruby on Rails 4.
I am trying to
require 'rest-client'
in my controller so that I can parse the login information I am getting from a form and send it to an API.
I can verify that the gem is installed and is also in my Gemfile on the application root.
However, it is still throwing the "cannot load such file -- rest-client " when I try to require the file in my controller.
I have googled the error and most of the answers I saw were either the gem wasn't installed, wasn't in the Gemfile, or a combination of both those. Neither is the situation here.
Is my controller unable to access the rest-client gem for some reason? I have to use rest-client because it is required in the API.
This is the line I used to install the gem:
gem install rest-client
This is the homepage of the gem: https://github.com/archiloque/rest-client
Which just redirects you to https://github.com/rest-client/rest-client
I should also note that it works fine when I wasn't using the code in a Rails project but just running the commands in the Terminal.
Assuming you're using https://github.com/rest-client/rest-client (since you didn't specify), your require line should be
require 'rest-client'
according to the README. Also, make sure you restart your rails server after adding the gem to your Gemfile and running bundle.
Run the following command in your terminal:
gem install rest-client
and use require 'rest-client'. No need to change to rest_client.
in my case, none of the solutions in this thread worked
what did work, was to add the gem directly in the Gemfile:
gem 'rest-client'
after closing the rails server, exiting rails console and running bundle install,
I opened again the rails console and this time require 'rest-client' worked flawlessly
For me it was an issue with bundle (which I thought I had installed). Spoiler alert, I didn't, and this is how I fixed it. I'm on a Mac running OS X Yosemite and my terminal version is Darwin Kernel Version 14.3.0:
cd
gem install bundler
or
cd
sudo gem install bundler
If you get something along the lines of the following error:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
Finally, change your require line from:
require 'rest-client'
to
require 'rest_client'
Then run your code!
First ensure you have installed gem 'rest-client', ~> 1.8.0 on your gem file. Run bundle install and then require 'rest_client'. This worked for me.
Try require 'rest_client', instead of require 'rest-client'
I am having issue connecting from ROR 3.2 to Oracle database.
irb(main):001:0> gem 'ruby-oci8', "~>2.1.0"
=> true
irb(main):002:0> gem 'activerecord-oracle_enhanced-adapter', '~> 1.4.1'
=> true
irb(main):003:0> exit
rails console
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require':
Please install the oracle_enhanced adapter: `gem install activerecord-o
racle_enhanced-adapter` (cannot load such file -- active_record/connection_adapters/oracle_enhanced_adapter) (LoadError)
I searched the web and it says i should create a gems file located at
https://github.com/rsim/oracle-enhanced/blob/master/Gemfile and then do a bundle install .
But i am new to rails and not sure how to do this any ideas please.
C:\kerbapp>bundle show activerecord-oracle_enhanced-adapter
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-oracle_enhanced-adapter-1.4.1
A rails application since 3.0 comes integrated with package management for gems called bundler (I recommend reading up more here). Any application will see only the gems included in its package list.
Your project should have a Gemfile file - add the gem 'activerecord-oracle_enhanced-adapter', '~> 1.4.1' line there, run bundle command from project root directory, and it should be good to go.
Keep in mind that when working with rails (and any sizable ruby project really) you should be adding all gems this way.