diff --git a/src/Drunit/Installer.php b/src/Drunit/Installer.php
index <HASH>..<HASH> 100644
--- a/src/Drunit/Installer.php
+++ b/src/Drunit/Installer.php
@@ -32,12 +32,7 @@ class Installer
         }
         
         // Drush messes with file permissions, so correct those first
-        $settingsFile = "{$drupal}/sites/default/settings.php";
-        chmod(dirname($settingsFile), 0777);
-        if (file_exists($settingsFile)) {
-            chmod($settingsFile, 0777);
-            unlink($settingsFile);
-        }
+        $this->fixPermissions($drupal);
         
         $process = $this->getProcess($drupal, $dsn);
 
@@ -48,6 +43,21 @@ class Installer
         }
     }
     
+    protected function fixPermissions($drupal) 
+    {
+        $settingsDir  = "{$drupal}/sites/default";
+        $settingsFile = "{$settingsDir}/settings.php";
+        if (!is_dir($settingsDir)) {
+            return;
+        }
+        chmod($settingsDir, 0777);
+        if (!file_exists($settingsFile)) {
+            return;
+        }
+        chmod($settingsFile, 0777);
+        unlink($settingsFile);
+    }
+    
     protected function getProcess($drupal, $dsn)
     {
         $builder = new ProcessBuilder();
@@ -60,3 +70,4 @@ class Installer
         return $process;
     }
 }
+
Check if settings dir is available first