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.
Related
I have installed the caldav-icloud gem. Then I've required it in my environment.rb
require "caldav-icloud"
But if I do rails s I get this error:
/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in `require': cannot load such file -- caldav-icloud (LoadError)
How can I solve it?
Thanks
To make any gem available to your Rails app, you have to add it to the Gemfile like this:
gem "caldav-icloud"
It is not enough to just install it.
This answer goes into a bit more detail what bundler and the Gemfile do and why this is required.
I'm new to Rails and I got a problem.
My new project requires rb-grib gem (link to ruby gems: https://rubygems.org/gems/rb-grib/versions/0.2.2). This gem requires GRIB API library, I installed it using brew install grib-api. It works in irb and .rb scripts. I need to use it in my Rails app, but I get an error LoadError: cannot load such file -- numru/grib. What I need to do to make it work and deploy to Heroku in future?
You need to add
require 'numru/grib'
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.
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.
I am trying to use the twitter-text-rb (https://github.com/twitter/twitter-text-rb) in my Rails 3 app.
I installed it using bundler and my gemfile - seemingly successfully - but when I try and include its autolink function in my Application Helper, like this:
require 'twitter-text'
module ApplicationHelper
include Twitter::Autolink
end
I get this error in the browser when I try to load the root of the app:
Routing Error
uninitialized constant Twitter::Autolink Try running rake routes for
more information on available routes.
I've followed these Troubleshooting Questions within the Ruby Gems manual but it doesn't seem to be either of the two likely issues that they suggest under "Why does require 'some_gem' fail?".
Here's the extract from when I followed their instructions from the root of my app using terminal:
manager$ gem list twitter-text
*** LOCAL GEMS ***
twitter-text (1.5.0)
manager$ ruby -rubygems -e 'require "twitter-text"'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:60:in `gem_original_require': no such file to load -- twitter-text (LoadError)
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:60:in `require'
from -e:1
manager$ gem contents --no-prefix twitter-text | grep lib
lib/twitter-text.rb
lib/twitter-text/autolink.rb
lib/twitter-text/deprecation.rb
lib/twitter-text/extractor.rb
lib/twitter-text/hit_highlighter.rb
lib/twitter-text/regex.rb
lib/twitter-text/rewriter.rb
lib/twitter-text/unicode.rb
lib/twitter-text/validation.rb
manager$ ruby -rubygems -e 'require "twitter-text"'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:60:in `gem_original_require': no such file to load -- twitter-text (LoadError)
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:60:in `require'
from -e:1
manager$ which ruby
/usr/bin/ruby
manager$ gem env | grep 'RUBY EXECUTABLE'
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
I'm using and handful of other gems in the app and haven't run into similar problems before.
I'm at a loss as what to try next. I'm pretty new to Ruby/Rails (and programming in general for that matter!) so any help would be much appreciated.
thanks,
Matt
I've now got this gem working and removed the Load Error (although I can't say for sure what went right).
I installed RVM and tried my app and the twitter_gem using Ruby 1.9.2 and Rails 3.2.3. I was previously using the system default Ruby - 1.8.7 - and Rails 3.2.3. The gem was loaded correctly and worked perfectly.
So it seems like the problem was with the gem working on the earlier version of Ruby or RVM's gemsets helped the app to load the gem correctly.