Tuesday, January 13, 2009

Solving LoadError problem on Mac OS X

Ruby's LoadError exception occurs when a file specified as a parameter to the load method cannot be loaded. This usually means that the file specified cannot be found in search path. To check if it really exists you should take a look your search path by opening the irb console and examining contents of $: array. Don't forget that gem method changes the contents of the array.

But what if file exists and you still got the problem? Check the privileges! When I installed textmate gem from Github, the textmate file (the one in /Library/Ruby/Gems/1.8/gems/wycats-textmate-0.9.2/bin/) had very weird set of privileges: -rwx-wx-wx. When I chmod-ed the file to 0755 (-rwxr-xr-x), which seems more logical anyways, everything worked as expected.

So, check your load paths and your privileges.