I have been debugging a bit an issue on our platform and I notice that our scanDirectory takes, from time to time, way to long, more than 100seconds. I have been looking at the default.settings.php and I noticed

 * The default list of directories that will be ignored by Drupal's file API.
 * By default ignore node_modules and bower_components folders to avoid issues
 * with common frontend tools and recursive scanning of directories looking for
 * extensions.
 * @see file_scan_directory()
 * @see \Drupal\Core\Extension\ExtensionDiscovery::scanDirectory()
$settings['file_scan_ignore_directories'] = [

I found that out that our sites/default directory is the one to blame. Can I just add it here? Or should I include the subdirectories(fx sites/default/files)?

I am really surprised about this one. Been working with drupal years now and I see this first time!

  • 1
    It's very unlikely Drupal itself is causing this problem, rather the server. Maybe there are too many files directly in sites/default/files - some file systems struggle to stat files whens there are a lot of them in a single folder, especially in virtual/networked envionrments
    – Clive
    Oct 23, 2020 at 16:20

1 Answer 1


If you need the file_scan_ignore_directories setting changed, you should add the $settings['file_scan_ignore_directories'] assignment in your settings.php, not default.settings.php lest it's overwritten when you update Drupal core.

Regarding what path strings to add to $settings['file_scan_ignore_directories'], that's up to you. As the comment block states, that setting affects all calls to ExtensionDiscovery::scanDirectory() and FileSystem::scanDirectory() (if a nomask option isn't specified).

Add the most inclusive path that you know will never contain extensions or files to be scanned/discovered.

  • Thanks for the answer. It's clear I need to edit stuff in settings.php. What is not clear is what is an extension. PHP extensions? At the moment underthe directory the cause problems I have my public files directory with all sorts of stuff -> pics, .csv stuff. Should I simply add $settings['file_scan_ignore_directories'] = "sites/default/files" ? Oct 23, 2020 at 7:28
  • Extensions are the term for any code package that extends Drupal functionality (i.e. modules, themes, install profiles, & theme engines). The class uses the scanDirectory method to look for .info.yml files to discover installable extensions.
    – Shawn Conn
    Oct 23, 2020 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.