On deleting all cache as

rm -rf var/cache/* var/page_cache/* var/view_preprocessed/* var/generation/*

I got below error

Warning: ltrim() expects parameter 1 to be string, object given in vendor\magento\framework\Code\Generator\EntityAbstract.php on line 152

Notice: Uninitialized string offset: 0 in vendor\magento\framework\Autoload\ClassLoaderWrapper.php on line 81

Notice: Uninitialized string offset: 0 in vendor\composer\ClassLoader.php on line 317

Notice: Uninitialized string offset: 0 in vendor\composer\ClassLoader.php on line 349
exception 'RuntimeException' with message 'Source class "" for   "Magento\Framework\App\Response\Http\Interceptor" generation does not exist.'
in vendor\magento\framework\Code\Generator.php:185 Stack trace:     #0  
vendor\magento\framework\Code\Generator.php(112): Magento\Framework\Code\Generator->tryToLoadSourceClass('Magento\\Framewo...', Object(Magento\Framework\Interception\Code\Generator\Interceptor)) #1 
vendor\magento\framework\Code\Generator\Autoloader.php(35): Magento\Framework\Code\Generator->generateClass('Magento\\Framewo...') #2 [internal function]: Magento\Framework\Code\Generator\Autoloader->load('Magento\\Framewo...') #3 
vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php(93): spl_autoload_call('Magento\\Framewo...') #4 
vendor\magento\framework\ObjectManager\Factory\Compiled.php(88): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\\Framewo...', Array) #5 
vendor\magento\framework\ObjectManager\Factory\Compiled.php(130): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\\Framewo...') #6 
vendor\magento\framework\ObjectManager\Factory\Compiled.php(67): Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\\Framewo...') #7     
vendor\magento\framework\ObjectManager\ObjectManager.php(57): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\\Framewo...', Array) #8 
vendor\magento\framework\App\Bootstrap.php(233): Magento\Framework\ObjectManager\ObjectManager->create('Magento\\Framewo...', Array) #9 
index.php(38): Magento\Framework\App\Bootstrap->createApplication('Magento\\Framewo...') #10 {main}

What are the reasons behind this issue?

Can you suggest me the possible solutions for this issue?

4 Answers 4


You have to first remove var folder.

Run command, php bin/magento setup:di:compile

After remove var folder give permission to var folder,

chmod -R 775 var/generation/ var/cache/ var/full_page/

Check again.

  • 4
    The error solved for me on compiling modules using php bin/magento setup:di:compile Oct 25, 2016 at 5:03
  • I have same issue and my issue also resolved using php bin/magento setup:di:compil comand Jan 6, 2018 at 6:26

If you're still having issues after compiling, removing the var/di folder & contents usually does the trick for me. No idea what actually causes this to happen though, I frequently run into it and would very much like to know.

  • 1
    Have you managed to find out why this is happening?
    – tread
    Jun 27, 2017 at 9:06

I had the same problem, I fixed it by giving the var directory 777 in permissions

cd magento root folder
sudo chmod 777 -R var/

now Magento can create di folder.


I also same problem below worked for me

cd <your Magento install dir> 
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
chown -R :www-data .   // I used LEMP/LAMP
chmod u+x bin/magento

php bin/magento setup:di:compile   // you can skip if know compile status
php bin/magento setup:static-content:deploy -f en_CA // if need your language code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.