Unable to apply patch MagentoInventorySalesSetupPatchSchemaInitializeWebsiteDefaultSock

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 MagentoInventorySalesSetupPatchSchemaInitializeW  
  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='' --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

Magento Asked on November 19, 2021

2 Answers

2 Answers

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

Answered by Jorge Henrique on November 19, 2021

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    2020-04-13 17:35:42.000000000 +0000
+++ Setup/Patch/Schema/InitializeStoresAndWebsites.php  2020-06-22 14:24:13.801830924 +0000
@@ -135,6 +135,7 @@
                 'is_active' => 1
+           MagentoFrameworkAppObjectManager::getInstance()->get(MagentoFrameworkAppConfig::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.

Answered by Adam on November 19, 2021

Add your own answers!

Related Questions

Magento 2 Access-Control-Allow-Origin

2  Asked on September 9, 2020 by borche-glafche


Magento 2: what is the catalog_attributes.xml file?

2  Asked on September 7, 2020 by raphael-at-digital-pianism


magento 2 – modify db_schema.xml field length

1  Asked on September 4, 2020 by sairaj-gadekar


Magento 2.3.2 Upgrade to 2.4

2  Asked on September 4, 2020 by hatim


Magento 2: Make sales without stock

1  Asked on August 9, 2020 by hudson-alves-triunfante


Magento 2 : print_r or var_dump is not working

4  Asked on July 30, 2020 by zed-blackbeard


Create quick order form at product page

0  Asked on July 29, 2020 by faraz-bashir


How to Special price based on attribute?

2  Asked on July 26, 2020 by user90560


is creating block within template in magento 2 good practice

0  Asked on July 24, 2020 by herve-tribouilloy


Ask a Question

Get help from others!

© 2021 All rights reserved.