0

I have just tried installing CiviCRM 5.30.1 using Drupal 7 under WIMP, i.e. Windows, IIS, MySQL and PHP 7.4, and was unable to do so, as I got a message telling me that \sites\default was not writable. On investigation, it seems that the PHP function is_writable will always return false under Windows. This means that it seems you can't install CiviCRM under Windows any more, as the IsCreatable function in \sites\all\modules\civicrm\setup\src\Setup\FileUtil.php relies on the is_writable function to test if the above folder is writable during the setup process. I got round it with the following code snippet.

public static function isCreateable($file) {
    if (file_exists($file)) {
      return is_writable($file);
    }

    $next = dirname($file);
    do {
      $current = $next;
        // Under Windows, it seems that folder are never writable      if (file_exists($current)) {
        if( is_writable($current)) {
          return true;
        } else {
          //Try to create a file
            $result = fopen("Test.tmp", "w");
            if ($result) {
            // Close the file.
            fclose($result);
            // Delete it.
            unlink("Test.tmp");
            return true;
            } else {
              return false;
            }
        }
      $next = dirname($current);
    } while ($current && $next && $current != $next);

    return FALSE;
  }

No doubt some of you CiviCRM experts will have a comment.

4
  • I install on windows often. Use attrib -r sites/default.
    – Demerit
    Nov 4, 2020 at 12:25
  • Typo: I meant attrib -r sites\default, with a backslash.
    – Demerit
    Nov 4, 2020 at 21:52
  • It is so long since I used DOS type commands - good thinking, that solved the problem! Nov 5, 2020 at 14:13
  • ok cool will post as answer
    – Demerit
    Nov 5, 2020 at 14:22

1 Answer 1

1

In windows to change the folder permissions use attrib -r path\to\sites\default (can be a relative or absolute path).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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