Directory index forbidden by Options directive

I wish I had a million dollars for every hour I've spent trying to track down little nagging problems I encounter in the process of developing custom modules for my Drupal clients. Truth is I'd settle for less. Truth is, just getting past some of them is reward enough. Today's was one of those.

I keep all my error logs for each of my development sites in a folder just off my dev server's document root. On my machine that's ~/mark/Sites/_logs. I keep it there so it's easy to find and check:

  1. periodically just to make sure nothing's awry
  2. when I'm having some kind of problem with the way a site is behaving
  3. just before deployment to production

This morning I checked it and found that the error.log for one of the sites I'm working on had grown fairly huge in too little time. I had only begun working on this site - really just laying out the framework for a new module - a few days before. Prior to that there was nothing in the error.log.

I opened the file and found hundreds of these:

[Mon Dec 05 14:12:01 2011] [error] [client 127.0.0.1] 
Directory index forbidden by Options directive: 
/Users/mark/Sites/example.dev/sites/all/modules/sc_2012/, 
referer: http://example.dev/content/example-url

The offending directory was always the same. The referring url was always a valid url on the site. In fact the problem seemed independent of the referring url because the error was being thrown on every page.

I spent a lot of time searching around trying to find what might be wrong. File and folder permissions were all correct. There were no stray .htaccess files in the folder structure, and I had left Drupal's .htaccess file untouched. It couldn't be a mis-set apache or php directive because I have plenty of other sites on this server that don't throw this error.

Everything I tried, renaming, moving, copying, refactoring... failed. I gave up for the moment. I had spent too much time on it and become frustrated. I took a break.

The break was just the ticket. It occurred to me that Drupal might be looking at the .info file for my module on every page load and that my module.info file had some unfinished business in it. Specifically, I had left three placeholders for files to be named at a later date:

stylesheets[all][] = 
dependencies[] = 
files[] = 

If you do this, Drupal will work just fine; but apache will fill up your error logs with this:

[Mon Dec 05 14:12:01 2011] [error] [client 127.0.0.1] 
Directory index forbidden by Options directive: 
/Users/mark/Sites/example.dev/sites/all/modules/sc_2012/, 
referer: http://example.dev/content/example-url
Powered by Drupal, an open source content management system