Getting .info file not found in my custom module, even though it does contain an .info file I am trying to install my custom module, but the error I get is:


  modulename.tar.gz does not contain any .info files.


My module tar.gz file does indeed contain a .info file. I have installed other modules on the server, so I shouldn't have any permission issues.

The following is the content of the .info file.


    name = Module Name  
    description = Initialization module for hl
    package = My modules
    core = 7.x
    files[] = modulename.module
    files[] = modulename.install
    files[] = modulename.inc
    files[] = includes/mydrupalusers.php
Mystery solved.

I traced back to the update_manager_install_form_submit() function in update.manager.inc.

When the file is uploaded, it is placed in the temp directory.  Drupal then creates a temp directory to extract the file into, using a unique directory name.  After the extraction, Drupal can't determine the module name any more, so it depends on the directory name in the archive. They commented on this in the code:

// Unfortunately, we can only use the directory name to determine the project
// name. Some archivers list the first file as the directory (i.e., MODULE/)
// and others list an actual file (i.e., MODULE/README.TXT).


I did not have my files tar'd in a directory.  So, I created a directory named after my module, moved the files into the directory, tar'd it up, and all is well.

Before


modulename.install  
modulename.module  


After


modulename/modulename.install  
modulename/modulename.module