I am trying to require a file located in lib (in my Rails app).
In development, this line works without any problems.
require "km"
However, in Heroku, I get a "no such file to load" error.
Via the Heroku console, I've tried a number of variants in terms of specifying paths to the file. For example:
require "lib/km"
require "./lib/km.rb"
And so forth. This is based on answers from these questions, which suggest that the issue is specifying the path to the file.
Rails, Heroku does not load my lib
Heroku console not loading file in /lib?
I've also tried adding this autoload line suggested here, which doesn't seem to solve it.
config.autoload_paths += Dir["#{config.root}/lib/**/"]
http://www.williambharding.com/blog/technology/rails-3-autoload-modules-and-classes-in-production/
How do I tell Rails to find the lib file? And why is there a difference in behaviour for require in development vs production?
UPDATE:
The issue turns out to be related to git. The original filename was "KM.rb", which was later changed to "km.rb". However, git didn't pick up the case change, so the change never got pushed onto the Heroku environment.
A key step was using the Ruby Dir commands in Heroku console to investigate the file structure and confirm the filename within the environment on Heroku.
require_relative
instead (if you're under Ruby 1.9). – jdoe