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
"Msvcrt-Ruby18.Dll Was Not Found" with Ruby
How to Read Files in an Eventmachine-Based App
What Does ["String"].Pack('H*') Mean
Installing Rmagick Gem -- Can't Find Magickwand.H
Set Locale Automatically in Ruby on Rails
Ruby Converting String Encoding from Iso-8859-1 to Utf-8 Not Working
Rails Custom Validation Based on a Regex
Ruby on Rails Multiple Http Request at the Same Time
Cannot Install Any Version of Ruby on Mojave - Internal Ranlib Command Failed
How to Inspect What Is the Default Value for Optional Parameter in Ruby's Method
Load Two Ruby Modules/Gems with the Same Name
How to Receive a JSON Object with Rack
How to Enable Chromedriver Logging in Ruby Capybara with Selenium
Call Ruby Script from Powershell
Axlsx Merge Cells Inside a Style
How to Ensure Ruby Gems Are Installed in Right Place to Be Executed by Bundler
Your Ruby Version Is 2.1.0, But Your Gemfile Specified 2.0.0
Rails Error Method_Missing': Undefined Method 'This' for Gem::Specification