vikash kumar vikash kumar - 3 months ago 9
Ruby Question

getting no such file to load -- xyz (LoadError)

I have cloned a ruby project from git hub,after cloning I performed bundle install. Now I am trying to run this project but getting require: no such file to load-- xyz (LoadError).


I am running my prj.rb file from bin and it contains



require 'xyz'


This xyz.rb is in the lib folder of my project.

Answer

One solution is to add lib directory to autoload by adding to config/application.rb

config.autoload_paths += %W(#{config.root}/lib)
config.autoload_paths += Dir["#{config.root}/lib/**/"]

Other

require "#{Rails.root}/lib/xyz"
Comments