Skip to content

setup:di:compile fails in CI pipeline #160

@mfickers

Description

@mfickers

After upgrading to 3.9.0 our CI pipelines fail for unit and integration tests.

In our unit test pipeline we run setup:di:compile in an environment without Magento being properly installed. There is no database or env.php.

Running bin/magento setup:di:compile fails with this error:


In WebsiteRepository.php line 159:
                                                                     
  The default website isn't defined. Set the website and try again.  
                                                                     

The same is true for our integration test pipeline, where we get this error when running the Magento install command.


In WebsiteRepository.php line 159:

  [DomainException]
  The default website isn't defined. Set the website and try again.


Exception trace:
  at /var/www/html/vendor/magento/module-store/Model/WebsiteRepository.php:159
 Magento\Store\Model\WebsiteRepository->getDefault() at /var/www/html/vendor/magento/module-store/Model/StoreResolver/Website.php:49
 Magento\Store\Model\StoreResolver\Website->getAllowedStoreIds() at /var/www/html/vendor/magento/module-store/Model/StoresData.php:67
 Magento\Store\Model\StoresData->getStoresData() at /var/www/html/vendor/magento/module-store/Model/StoreResolver.php:138
 Magento\Store\Model\StoreResolver->getStoresData() at /var/www/html/vendor/magento/module-store/Model/StoreResolver.php:97
 Magento\Store\Model\StoreResolver->getCurrentStoreId() at /var/www/html/generated/code/Magento/Store/Model/StoreResolver/Proxy.php:105
 Magento\Store\Model\StoreResolver\Proxy->getCurrentStoreId() at /var/www/html/vendor/magento/module-store/Model/StoreManager.php:159
 Magento\Store\Model\StoreManager->getStore() at /var/www/html/vendor/justbetter/magento2-sentry/Helper/Data.php:320
 JustBetter\Sentry\Helper\Data->getStore() at /var/www/html/vendor/justbetter/magento2-sentry/Helper/Data.php:199
 JustBetter\Sentry\Helper\Data->getStoreId() at /var/www/html/vendor/justbetter/magento2-sentry/Helper/Data.php:209
 JustBetter\Sentry\Helper\Data->collectModuleConfig() at /var/www/html/vendor/justbetter/magento2-sentry/Helper/Data.php:75
 JustBetter\Sentry\Helper\Data->__construct() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:121
 Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/Compiled.php:108
 Magento\Framework\ObjectManager\Factory\Compiled->create() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/Compiled.php:150
 Magento\Framework\ObjectManager\Factory\Compiled->get() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/Compiled.php:79
 Magento\Framework\ObjectManager\Factory\Compiled->create() at /var/www/html/vendor/magento/framework/ObjectManager/ObjectManager.php:73
 Magento\Framework\ObjectManager\ObjectManager->get() at /var/www/html/vendor/magento/framework/Logger/LoggerProxy.php:101
 Magento\Framework\Logger\LoggerProxy->getLogger() at /var/www/html/vendor/magento/framework/Logger/LoggerProxy.php:140
 Magento\Framework\Logger\LoggerProxy->error() at /var/www/html/vendor/magento/framework/Console/Cli.php:121
 Magento\Framework\Console\Cli->doRun() at /var/www/html/vendor/symfony/console/Application.php:175
 Symfony\Component\Console\Application->run() at /var/www/html/bin/magento:23

I think this bug was introduced with the changes from b4fd7e1

Activity

indykoning

indykoning commented on Feb 17, 2025

@indykoning
Member

Hi, i have a similar setup where the env.php does not exist during the compilation step.
Unfortunately though i am unable to reproduce this myself, having successfully deployed multiple sites.

If you find what is causing it for you i'd happily accept a PR!

moston

moston commented on Mar 3, 2025

@moston

@mfickers check your app/etc/config.php if you have proper website's set there - in my case it was duplicated is_default = 1 websites

MartinVanVan

MartinVanVan commented on Mar 27, 2025

@MartinVanVan

Hi, i have a similar setup where the env.php does not exist during the compilation step. Unfortunately though i am unable to reproduce this myself, having successfully deployed multiple sites.

If you find what is causing it for you i'd happily accept a PR!

You can reproduce this by setting your local magento project in production mode and delete (or rename) you env.php.
Then just run magento setup:di:compile

added a commit that references this issue on May 6, 2025
2645556
added theissue type on May 6, 2025
indykoning

indykoning commented on May 6, 2025

@indykoning
Member

If i am to believe #169 this should now be fixed in V4.0.1 🚀

If the issue persists, feel free to reopen the issue

rsanderbasecom

rsanderbasecom commented on Jun 13, 2025

@rsanderbasecom

If i am to believe #169 this should now be fixed in V4.0.1 🚀

If the issue persists, feel free to reopen the issue

unfortunately this issue still exists after the changes in V4.0.1. I tested it on V4.2.0 and it is the same error as @mfickers already mentioned. Had to downgrade it to 3.8.0

indykoning

indykoning commented on Jun 13, 2025

@indykoning
Member

Could you see and try wether #188 fixes your issue.
It should catch the error that the website is missing, and return null instead which we expect could be the case in other parts of the code

rsanderbasecom

rsanderbasecom commented on Jun 16, 2025

@rsanderbasecom

Could you see and try wether #188 fixes your issue. It should catch the error that the website is missing, and return null instead which we expect could be the case in other parts of the code

Thanks for your quick response. I've tested your fix but i still get an error.

This is my Stacktrace:

In WebsiteRepository.php line 159:

  [DomainException]
  The default website isn't defined. Set the website and try again.


Exception trace:
  at /var/www/html/vendor/magento/module-store/Model/WebsiteRepository.php:159
 Magento\Store\Model\WebsiteRepository->getDefault() at /var/www/html/vendor/magento/module-store/Model/StoreResolver/Website.php:49
 Magento\Store\Model\StoreResolver\Website->getAllowedStoreIds() at /var/www/html/vendor/magento/module-store/Model/StoresData.php:67
 Magento\Store\Model\StoresData->getStoresData() at /var/www/html/vendor/magento/module-store/Model/StoreResolver.php:138
 Magento\Store\Model\StoreResolver->getStoresData() at /var/www/html/vendor/magento/module-store/Model/StoreResolver.php:97
 Magento\Store\Model\StoreResolver->getCurrentStoreId() at /var/www/html/generated/code/Magento/Store/Model/StoreResolver/Proxy.php:105
 Magento\Store\Model\StoreResolver\Proxy->getCurrentStoreId() at /var/www/html/vendor/magento/module-store/Model/StoreManager.php:159
 Magento\Store\Model\StoreManager->getStore() at /var/www/html/generated/code/Magento/Store/Model/StoreManagerInterface/Proxy.php:129
 Magento\Store\Model\StoreManagerInterface\Proxy->getStore() at /var/www/html/vendor/magento/module-store/Model/Resolver/Store.php:30
 Magento\Store\Model\Resolver\Store->getScope() at /var/www/html/vendor/magento/framework/App/Config/ScopeCodeResolver.php:49
 Magento\Framework\App\Config\ScopeCodeResolver->resolve() at /var/www/html/vendor/magento/framework/App/Config.php:68
 Magento\Framework\App\Config->getValue() at /var/www/html/vendor/justbetter/magento2-sentry/Helper/Data.php:228
 JustBetter\Sentry\Helper\Data->collectModuleConfig() at /var/www/html/vendor/justbetter/magento2-sentry/Helper/Data.php:106
 JustBetter\Sentry\Helper\Data->__construct() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:121
 Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/Compiled.php:108
 Magento\Framework\ObjectManager\Factory\Compiled->create() at /var/www/html/vendor/magento/framework/ObjectManager/ObjectManager.php:73
 Magento\Framework\ObjectManager\ObjectManager->get() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:170
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:276
 Magento\Framework\ObjectManager\Factory\AbstractFactory->getResolvedArgument() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:239
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/Compiled.php:101
 Magento\Framework\ObjectManager\Factory\Compiled->create() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/Compiled.php:150
 Magento\Framework\ObjectManager\Factory\Compiled->get() at /var/www/html/vendor/magento/framework/ObjectManager/Factory/Compiled.php:79
 Magento\Framework\ObjectManager\Factory\Compiled->create() at /var/www/html/vendor/magento/framework/ObjectManager/ObjectManager.php:73
 Magento\Framework\ObjectManager\ObjectManager->get() at /var/www/html/vendor/magento/framework/Logger/LoggerProxy.php:101
 Magento\Framework\Logger\LoggerProxy->getLogger() at /var/www/html/vendor/magento/framework/Logger/LoggerProxy.php:140
 Magento\Framework\Logger\LoggerProxy->error() at /var/www/html/vendor/magento/framework/Console/Cli.php:121
 Magento\Framework\Console\Cli->doRun() at /var/www/html/vendor/symfony/console/Application.php:175
 Symfony\Component\Console\Application->run() at /var/www/html/bin/magento:23

I think the collectModuleConfig() function is also the problem...

indykoning

indykoning commented on Jun 16, 2025

@indykoning
Member

I think you're right, i've updated the PR that should be caught as well now!
Could you give it a try?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @moston@mfickers@indykoning@MartinVanVan@rsanderbasecom

      Issue actions

        setup:di:compile fails in CI pipeline · Issue #160 · justbetter/magento2-sentry