I have a module "A" that depends on another module "B".

The dependency is defined in composer.json and in the <sequence> node. But this shouldn't be relevant.

However, I'm testing another branch/feature of the project that would remove the "B" module (that I am still developing).

So, I disabled module "A" to avoid errors with its dependencies.

✅ It's listed in the disabled modules.
✅ I cleaned the cache, and also ran setup:up before compile.

However, even after cleaning generated folder, my setup:di:compile fails because of some Plugin class of (disabled) module "A" that relies on module "B" that no longer exist.

Fatal error: Uncaught Error: Class 'Module\B\Model\SomeClass' not found in /var/www/html/app/code/Module/A/Plugin/SomeClassPlugin.php:6

Is this a Magento bug, poor design, or I am missing something?

As far as I know, Magento should not compile classes in disabled modules. Am I right?

  • from where you disable the module? from the config.php? Jul 15, 2021 at 5:07
  • Indirectly, yes. I used bin/magento module:disable Module_A. Jul 15, 2021 at 7:48

1 Answer 1


As far as I know and understand from the compile command (Magento\Setup\Console\Command\DiCompileCommand) it just simply scans the filessystem for components to register and include in the compilation. It doesn't actually check if the module is enabled or not.

So to truly exclude a module from compilation you'll need to either remove/rename registration.php from the module, or remove the module all together.

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.