I upgraded a number of module but when I come to compile (bin/magento setup:di:compile) I get the error below. Anyone know how to fix it? Thank you Andy
Repositories code generation... 1/9 [===>------------------------] 11% < 1 sec 104.0 MiBCall to undefined function Composer\Autoload\includeFile()#0 /var/www/vhosts/mysite.co.uk/htdocs/public_html/vendor/composer/ClassLoader.php(578): include()
#1 /var/www/vhosts/mysite.co.uk/htdocs/public_html/vendor/composer/ClassLoader.php(432): Composer\Autoload\ClassLoader::Composer\Autoload\{closure}()
#2 [internal function]: Composer\Autoload\ClassLoader->loadClass()
#3 [internal function]: spl_autoload_call()
#4 /var/www/vhosts/mysite.co.uk/htdocs/public_html/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(134): class_exists()
#5 /var/www/vhosts/mysite.co.uk/htdocs/public_html/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(117): Magento\Setup\Module\Di\Code\Reader\ClassesScanner->includeClass()
#6 /var/www/vhosts/mysite.co.uk/htdocs/public_html/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(87): Magento\Setup\Module\Di\Code\Reader\ClassesScanner->extract()
#7 /var/www/vhosts/mysite.co.uk/htdocs/public_html/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php(61): Magento\Setup\Module\Di\Code\Reader\ClassesScanner->getList()
#8 /var/www/vhosts/mysite.co.uk/htdocs/public_html/setup/src/Magento/Setup/Module/Di/App/Task/Manager.php(56): Magento\Setup\Module\Di\App\Task\Operation\RepositoryGenerator->doOperation()
#9 /var/www/vhosts/mysite.co.uk/htdocs/public_html/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php(216): Magento\Setup\Module\Di\App\Task\Manager->process()
#10 /var/www/vhosts/mysite.co.uk/htdocs/public_html/vendor/symfony/console/Command/Command.php(255): Magento\Setup\Console\Command\DiCompileCommand->execute()
#11 /var/www/vhosts/mysite.co.uk/htdocs/public_html/vendor/symfony/console/Application.php(1021): Symfony\Component\Console\Command\Command->run()
#12 /var/www/vhosts/mysite.co.uk/htdocs/public_html/vendor/symfony/console/Application.php(275): Symfony\Component\Console\Application->doRunCommand()
#13 /var/www/vhosts/mysite.co.uk/htdocs/public_html/vendor/magento/framework/Console/Cli.php(115): Symfony\Component\Console\Application->doRun()
#14 /var/www/vhosts/mysite.co.uk/htdocs/public_html/vendor/symfony/console/Application.php(149): Magento\Framework\Console\Cli->doRun()
#15 /var/www/vhosts/mysite.co.uk/htdocs/public_html/bin/magento(23): Symfony\Component\Console\Application->run()
#16 {main}
You have new mail in /var/spool/mail/mysite`
-bash-4.2$
Still struggling with this.
I found some advice to find which class is causing issues by adding echo "Class: ".$path."\n to the /setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php file.
Now I'm getting the below when running setup:di:compile
syntax error, unexpected '$realPath' (T_VARIABLE), expecting ';' or ','#0 /var/www/vhosts/mysite.co.uk/public_html/vendor/composer/ClassLoader.php(432): Composer\Autoload\ClassLoader::Composer\Autoload{closure}() #1 [internal function]: Composer\Autoload\ClassLoader->loadClass() #2 [internal function]: spl_autoload_call() #3 /var/www/vhosts/mysite.co.uk/public_html/vendor/magento/framework/Code/Reader/ClassReader.php(71): ReflectionClass->__construct() #4 /var/www/vhosts/mysite.co.uk/public_html/vendor/magento/framework/Code/Reader/ClassReader.php(36): Magento\Framework\Code\Reader\ClassReader->getParameterClass() #5 /var/www/vhosts/mysite.co.uk/public_html/vendor/magento/framework/ObjectManager/Definition/Runtime.php(54): Magento\Framework\Code\Reader\ClassReader->getConstructor() #6 /var/www/vhosts/mysite.co.uk/public_html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(48): Magento\Framework\ObjectManager\Definition\Runtime->getParameters() #7 /var/www/vhosts/mysite.co.uk/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(56): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() #8 /var/www/vhosts/mysite.co.uk/public_html/setup/src/Magento/Setup/Module/Di/App/Task/OperationFactory.php(109): Magento\Framework\ObjectManager\ObjectManager->create() #9 /var/www/vhosts/mysite.co.uk/public_html/setup/src/Magento/Setup/Module/Di/App/Task/Manager.php(38): Magento\Setup\Module\Di\App\Task\OperationFactory->create() #10 /var/www/vhosts/mysite.co.uk/public_html/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php(189): Magento\Setup\Module\Di\App\Task\Manager->addOperation() #11 /var/www/vhosts/mysite.co.uk/public_html/vendor/symfony/console/Command/Command.php(255): Magento\Setup\Console\Command\DiCompileCommand->execute() #12 /var/www/vhosts/mysite.co.uk/public_html/vendor/symfony/console/Application.php(1021): Symfony\Component\Console\Command\Command->run() #13 /var/www/vhosts/mysite.co.uk/public_html/vendor/symfony/console/Application.php(275): Symfony\Component\Console\Application->doRunCommand() #14 /var/www/vhosts/mysite.co.uk/public_html/vendor/magento/framework/Console/Cli.php(115): Symfony\Component\Console\Application->doRun() #15 /var/www/vhosts/mysite.co.uk/public_html/vendor/symfony/console/Application.php(149): Magento\Framework\Console\Cli->doRun() #16 /var/www/vhosts/mysite.co.uk/public_html/bin/magento(23): Symfony\Component\Console\Application->run()
Line 432 of the /var/www/vhosts/mysite.co.uk/public_html/vendor/composer/ClassLoader.php(432): Is (self::$includeFile)($file);
Tu Van I did try removing the vendor folder but this didn't work either. Hope someone can advise. Andy
1 Answer 1
There is a syntax error either correct it by hand or as suggested delete the whole vendor folder and reinstall it. Be careful when editing magento core files. Here I list some commands that may be useful to you.
If you can manually fix the error after run the command, composer dump autoload php bin/magento setup:di:compile .
Otherwise use the command rm -rf vendor composer install
-
Hi Gennaro Before I run the rm -rf vendor composer install How would I manually fix the syntax error? The error code suggests the error is at Line 432 of the /var/www/vhosts/mysite.co.uk/public_html/vendor/composer/ClassLoader.php(432): Which is (self::$includeFile)($file); but this line does contain the ; Thank youAndyJH– AndyJH2023年03月01日 14:50:24 +00:00Commented Mar 1, 2023 at 14:50
-
I copied the ClassLoader.php from a working dev site to the effected site and can now run the command bin/magento setup:di:compile There were differences in the other ClassLoader.php file. I just hope this won't have any negative effect later on.AndyJH– AndyJH2023年03月01日 16:45:24 +00:00Commented Mar 1, 2023 at 16:45
-
Don't worry, I always suggest you copy the files either from the official version of magento on github or I suggest you download a virgin open source version in zip format so you can always go and check the differences.GerranoMargeno– GerranoMargeno2023年03月07日 10:08:14 +00:00Commented Mar 7, 2023 at 10:08
vendordirectory and runcomposer install.