Question

Having issue in setup:di:compile and give below issue

enter image description here

Already checked: Magento 2 Setup di Compile Problem

Magento Vesion: 2.3.1

Update 1:

If i try with command bin/magento setup:di:compile -vvv, it gives below error

[root@server httpdocs]# bin/magento setup:di:compile -vvv
Compilation was started.
Area configuration aggregation... 5/7 [====================>-------]  71% 44 secs 287.0 MiB

In ClassReader.php line 35:

  [ReflectionException]
  Class Magento\InventorySalesApi\Api\AreProductsSalableInterface does not exist


Exception trace:
 () at /SITE_PATH/httpdocs/vendor/magento/framework/Code/Reader/ClassReader.php:35
 Magento\Framework\Code\Reader\ClassReader->getConstructor() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassReaderDecorator.php:35
 Magento\Setup\Module\Di\Code\Reader\ClassReaderDecorator->getConstructor() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/Code/Reader/Decorator/Area.php:53
 Magento\Setup\Module\Di\Code\Reader\Decorator\Area->getList() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Area.php:112
 Magento\Setup\Module\Di\App\Task\Operation\Area->getDefinitionsCollection() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Area.php:87
 Magento\Setup\Module\Di\App\Task\Operation\Area->doOperation() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/App/Task/Manager.php:56
 Magento\Setup\Module\Di\App\Task\Manager->process() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php:206
 Magento\Setup\Console\Command\DiCompileCommand->execute() at /SITE_PATH/httpdocs/vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /SITE_PATH/httpdocs/vendor/symfony/console/Application.php:893
 Symfony\Component\Console\Application->doRunCommand() at /SITE_PATH/httpdocs/vendor/symfony/console/Application.php:262
 Symfony\Component\Console\Application->doRun() at /SITE_PATH/httpdocs/vendor/magento/framework/Console/Cli.php:102
 Magento\Framework\Console\Cli->doRun() at /SITE_PATH/httpdocs/vendor/symfony/console/Application.php:145
 Symfony\Component\Console\Application->run() at /SITE_PATH/httpdocs/bin/magento:23

In ClassReader.php line 29:
  
[ReflectionException]
  Class Magento\InventorySalesApi\Api\AreProductsSalableInterface does not exist


Exception trace:
 () at /SITE_PATH/httpdocs/vendor/magento/framework/Code/Reader/ClassReader.php:29
 ReflectionParameter->getClass() at /SITE_PATH/httpdocs/vendor/magento/framework/Code/Reader/ClassReader.php:29
 Magento\Framework\Code\Reader\ClassReader->getConstructor() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassReaderDecorator.php:35
 Magento\Setup\Module\Di\Code\Reader\ClassReaderDecorator->getConstructor() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/Code/Reader/Decorator/Area.php:53
 Magento\Setup\Module\Di\Code\Reader\Decorator\Area->getList() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Area.php:112
 Magento\Setup\Module\Di\App\Task\Operation\Area->getDefinitionsCollection() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Area.php:87
 Magento\Setup\Module\Di\App\Task\Operation\Area->doOperation() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/App/Task/Manager.php:56
 Magento\Setup\Module\Di\App\Task\Manager->process() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php:206
 Magento\Setup\Console\Command\DiCompileCommand->execute() at /SITE_PATH/httpdocs/vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /SITE_PATH/httpdocs/vendor/symfony/console/Application.php:893
 Symfony\Component\Console\Application->doRunCommand() at /SITE_PATH/httpdocs/vendor/symfony/console/Application.php:262
 Symfony\Component\Console\Application->doRun() at /SITE_PATH/httpdocs/vendor/magento/framework/Console/Cli.php:102
 Magento\Framework\Console\Cli->doRun() at /SITE_PATH/httpdocs/vendor/symfony/console/Application.php:145
 Symfony\Component\Console\Application->run() at /SITE_PATH/httpdocs/bin/magento:23

setup:di:compile

Update: 2

This is result if i try find by:

find -type f -iname '*.php' -print0 | xargs -0 grep -nw -e 'Magento\InventorySalesApi\Api\AreProductsSalableInterface'

enter image description here

No correct solution

OTHER TIPS

It seems that the package magento/module-inventory-sales-api doesn't exists yet on Magento 2.3.1

I have projects that are running 2.3.x and 2.4.x and run find . -name "AreProductsSalableInterface.php". Only the project on 2.4.x returned a match which tells me that 2.3.x doesn't have yet that package.

Also the InventorySalesApi started appearing on version 1.1.5 https://github.com/magento/inventory/tree/1.1.5/InventorySalesApi

If all else fails you could try setting up the file - proceed with caution! https://github.com/magento/inventory/tree/1.2-develop/InventorySalesApi/Api Might need both AreProductsSalableInterface.php and AreProductsSalableForRequestedQtyInterface.php

I think it can be one of reason which mentioned below:

  1. Maybe a permission issue, try to run compilation command after giving proper permission to var/ pub/ generated folder.

php bin/magento setup:di:compile

  1. It may be the composer upgrade/install command not correctly. Please run below command

composer update

  1. If you are still facing the same issue then please try to disable all your custom extensions and them and run the below command. If this will work correctly then it is clear that you have an issue with custom themes or extensions.

php bin/magento setup:upgrade

php bin/magento setup:di:comiple

If the above suggestion/solutions don't work, please let me know, I will try to help you.

Thanks

  • php bin/magento list #If this gives you error check which module causing issue
  • php bin/magento setup:upgrade # upgrade the setup
  • php bin/magento setup:di:compile #compilation code
  • php bin/magento setup:static-content:deploy -f #static content display


  • chown apache:apache -Rf var/ # set permission for apache server cache
  • chmod -R 777 var/ pub/ # set permisiion to store cache in PUB folder
  • Licensed under: CC-BY-SA with attribution
    Not affiliated with magento.stackexchange
    scroll top