2

Getting following error while compilation using this command : php bin/magento setup:di:compile after upgrade Magento 2.1.7 to 2.1.9 check below error for more information :

Warning: ltrim() expects parameter 1 to be string, array given in /MagentoRoot/setup/src/Magento/Setup/Module/Di/Compiler/Config/Chain/BackslashTrim.php on line 61

3

4 Answers 4

4

I came across this and turned out to be an issue when you run integration tests at some point before running bin/magento setup:di:compile.

Integration tests generate some test modules in app/code/Magento which are then picked up by the setup:di:compile command. enter image description here I fixed this by removing the Magento folder from app/code.

1

I would assume this is related to (read/write/execute) to var and pub directory.

sudo chmod -R 777 var pub

Also, try clearing the cache

sudo rm -rf var/cache/* var/generation/*

However it might be something to do with the di folder, this might also work:

  1. Delete the di folder from the var directory
  2. sudo php bin/magento setup:di:compile
  3. Reset file permissions.
3
  • I have already tried this lots of times. but getting error every time. Oct 2, 2017 at 11:02
  • delete vendor and reinstall. Have you tried this ?
    – andy jones
    Oct 2, 2017 at 11:10
  • FYI site is working fine but compilation not working. Also can you please tell me what needs to be reinstall ? Oct 2, 2017 at 11:14
0

I am facing the same issue after upgrading to Magento2.4.2-p1. I did some analysis on this and got the reason for this error. Actually, Magento installed some new modules like Magento_TestModuleAsyncAmqp, Magento_TestModuleExtensionAttributes etc. When you go to file

app/code/Magento/TestModuleExtensionAttributes/Api/Data/FakeExtensibleTwoInterface.php

you will see

/**
     * test incorrect return type
     *
     * **@return int**
     */
    public function getExtensionAttributes();

So, here it is asking to provide class as return type instead of @return int If you will add below class as return type then it should work.

\Magento\TestModuleExtensionAttributes\Api\Data\FakeExtensibleTwoExtensionInterface|int

Try to provide class here and then run di:compile again after clearing cache, generation etc

-1

Issue fixed after run following commands in root directory

644 permission for files

find . -type f -exec chmod 644 {} \;

755 permission for directory

find . -type d -exec chmod 755 {} \;

777 permission for var folder

find ./var -type d -exec chmod 777 {} \;

And following commands for pub/media and pub/static

find ./pub/media -type d -exec chmod 777 {} \;

find ./pub/static -type d -exec chmod 777 {} \;

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.