vikash kumar vikash kumar - 1 year ago 88
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 Source

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/**/"]


require "#{Rails.root}/lib/xyz"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download