When running a fresh install I am presented with this error. This is using the lastest composer package, as per the Magento docs.

[Progress: 113 / 1106]
Module 'Magento_InventorySales':
In PatchApplier.php line 247:
  Unable to apply patch Magento\InventorySales\Setup\Patch\Schema\InitializeW  
  ebsiteDefaultSock for module Magento_InventorySales. Original exception mes  
  sage: The default website isn't defined. Set the website and try again.

The install command I am using is: php bin/magento setup:install --base-url='https://YYY.mdoq.io/' --db-host='****' --db-name='magento' --db-user='magento' --db-password='****' --admin-firstname='Admin' --admin-lastname='Admin' --admin-email='admin' --admin-user='admin' --admin-password='****' --language='en_GB' --currency='GBP' --timezone='Europe/London' --use-rewrites=1 --cleanup-database

4 Answers 4


The issue is because during the install process Magento installs the store data, but then doesn't flush its cache. (Not actual cache written to disk/redis but the in memory cache of the object) As far as it is concerned there are still no stores in the DB, because there wasn't first time it checked. (Before they were pushed into the DB) To get around this:

  1. make sure you have cweagans/composer-patches installed (composer require cweagans/composer-patches:1.6.7)
  2. add the following to your composer.json
"extra": {
      "patches": {
          "magento/module-store": {
              "Cache not cleared during install": "patches/magento_install_clear_cache.patch"
  1. Add patches/magento_install_clear_cache.patch with content (don't miss the newline at the end of the file):
--- ./Setup/Patch/Schema/InitializeStoresAndWebsites.php
+++ ./Setup/Patch/Schema/InitializeStoresAndWebsites.php
@@ -135,6 +135,9 @@
                     'is_active' => 1
+            \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Framework\App\Config::class)->clean();
  1. composer update
  2. rm -rf vendor/magento/module-store
  3. composer install --no-dev
  4. then re-run your install command and all should be gravy.
  • Hi ! I tried to apply your patch but I'm getting the error : Could not apply patch! Skipping. The error was: Cannot apply patch patches/magento_install_clear_cache.patch do you have any idea why ? thanks !
    – magentodev
    Oct 21, 2020 at 11:51
  • Can you run: vendor/magento/module-store; composer install --no-dev -vvv Then post the output? (should give you a load of debug as to why the patch failed to apply)
    – Adam
    Oct 23, 2020 at 9:09

An alternative to Adam's answer, is to delete env.php at app/etc folder and run the setup again.

  • This should be the accepted answer :) Just move the .env out of the way for a minute.
    – rfay
    Jul 14, 2021 at 16:24

Please remove your Database and create new DB again than restart install again. It's working perfectly.


Delete the env file, run composer install, and run the bin/magento setup install with the flag --cleanup-database

Your Answer

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

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