Thursday, 9 August 2012

Ruby LoadError: cannot load such file

So, you've set yourself up a lovely new app using, for example, Sinatra, and you're really chaffing at the bit to write some lovely code. But you keep getting bit by this:
LoadError: cannot load such file -- sweetsweetcode
You double check your config.ru but it is pretty standard stuff:
require 'sweetsweetcode'
run Sinatra::Application
What can be wrong? Please tell me oh gods of Ruby. Is it Passenger? Is it Rack? Have I uncovered a great big bug in Ruby itself? Naaaa! Of course not you fool, it's just that you're on the very latest version of Ruby, probably 1.9.3 or something and the load path no longer includes the current path. So to fix it, just do this:
require './sweetsweetcode'
run Sinatra::Application
And you should be singing again.

1 comment:

  1. Thanks man. I was googling for this since hours!

    ReplyDelete