Rails on Windows – nil object when you didn’t expect it

If you jump between Linux and Windows XP like I do, sometimes you’ll pull your Rails app into the dreaded M$ platform, fire it up and be greeted with a lovely “Internal Server Error”. Naturally it goes on to say something like “You have a nil object when you didn’t expect it! You might have expected an instance of Array. The error occurred while evaluating nil.each” despite the fact that you’ve changed no code since last night when your app was running rather nicely in a Linux environment thank you very much. Sometimes you just need to hack your way out of a problem without worrying about the whys and wherefores – and that’s exactly what we are going to do here. So……open up configenvironmentsdevelopment.rb and find this line :

config.logger = Logger.new(config.log_path, 2, 10.kilobytes)

comment it out comme ca

#config.logger = Logger.new(config.log_path, 2, 10.kilobytes)

and fire it up again. All good? Yes? Excellent. Fixed. Why? Um. Log rotation in XP apparently. Something funny about it. Don’t really know. Haven’t investigated it much further because there is no way in hell I’m going to run a production Rails app in Windows. Ever.