Gem Found in Irb, Not in Ruby

Custom gem works in irb, not in a ruby script

You are trying to load scommon, but that file does not lie in the load path. You could use the 'full' path: require 'commenfiles/scommon'

Note, that this happens, because the file's directory ist not part of the load path. I recommend using require_relative instead (it does not use the load path): require_relative 'scommon'

Gem loads in irb but not console

require returns false if that file has already been loaded. Try it out in your irb session by performing the require statement twice in a row. The second one will return false:

irb(main):001:0> require 'nokogiri'
=> true
irb(main):002:0> require 'nokogiri'
=> false

If the file could not be found, require will raise a LoadError instead.

Your exception message (No such file to load -- Nokogiri), makes it seem like something is requiring 'Nokogiri' instead of 'nokogiri', which might be a problem on a case-sensitive operating system.

Gem available in irb but not rails console

Does your rails project's Gemfile include gem 'RedCloth' in it? Rails will only load the gems specified in that file.

Gem can be required in IRB but not by Rails

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.

Ruby not finding gems, but they appear on gem list, and work in irb console?

dameon-kit uses bundler, so you don't need to include rubygems. Include the following lines to your Gemfile :

gem 'resque'
gem 'hoptoad_notifier'

Run bundle install

and include your gems as usual :

require 'resque'
require 'hoptoad_notifier'

It worked for me.



Related Topics



Leave a reply



Submit