PHP Warning: include(): realpath failed to canonicalize

I was getting the following warnings when I was running Magento shell scripts from the command line using PHP CLI (PHP Command Line Interface).


PHP Warning:  include(): realpath failed to canonicalize Mage/Core/Model/App.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93

PHP Warning:  include(): realpath failed to canonicalize Varien/Event/Collection.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93

PHP Warning:  include(): realpath failed to canonicalize Varien/Event/Observer/Collection.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93

PHP Warning:  include(): realpath failed to canonicalize Mage/Core/Model/Config.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93

PHP Warning:  include(): realpath failed to canonicalize Mage/Core/Model/Config/Base.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93

PHP Warning:  include(): realpath failed to canonicalize Varien/Simplexml/Config.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93

PHP Warning:  include(): realpath failed to canonicalize Mage/Core/Model/Config/Options.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93

PHP Warning:  include(): realpath failed to canonicalize Varien/Object.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93

PHP Warning:  include(): realpath failed to canonicalize Varien/Profiler.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93

PHP Warning:  include(): realpath failed to canonicalize Zend/Log.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93

PHP Warning:  include(): realpath failed to canonicalize Mage/Core/Model/Store/Exception.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93

PHP Warning:  include(): realpath failed to canonicalize Mage/Core/Exception.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93

PHP Warning:  include(): realpath failed to canonicalize Zend/Log/Formatter/Simple.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93

PHP Warning:  include(): realpath failed to canonicalize Zend/Log/Formatter/Interface.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93

PHP Warning:  include(): realpath failed to canonicalize Zend/Log/Writer/Stream.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93

PHP Warning:  include(): realpath failed to canonicalize Zend/Log/Writer/Abstract.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93

PHP Warning:  include(): realpath failed to canonicalize Zend/Log/FactoryInterface.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93

To remove these warnings I started debugging Magento code but no success. Then I Googled and came across various posts/forums saying that it was possibly due to APC.

My web hosting environment had:

  • Ubuntu 12.04
  • Nginx 1.4.5
  • PHP 5.4.3
  • Percona Server 5.5 (MySql)
  • APC 3.1.13

To verify whether warnings were really due to APC or not I disabled it and ran the Magento shell script again. This time all warnings disappeared proving that they were due to APC.

Now as per the suggestions available I checked my APC settings. I had the following APC settings in /etc/php5/cli/php.ini


[APC]

extension=apc.so
apc.enabled =1
apc.shm_segments = 1
apc.shm_size = 512M
apc.ttl = 7200
apc.user_ttl  = 7200
apc.num_files_hint = 1024
apc.mmap_file_mask = /tmp/apc.XXXXXX
apc.enable_cli = 1
apc.cache_by_default  = 1
apc.max_file_size = 10M
apc.stat = 0

I changed ‘apc.stat’ from


apc.stat=0

to


apc.stat=1

After cleaning the APC cache and the Magento cache, I ran the script again. Now there were no warnings displayed.

A bug related to the APC issue had been logged “Bug #59493     APC fails to include files with relative paths and apc.stat=0

“apc.stat=1” forces APC to stat (check) the script on each request to determine if it has been modified. If it has been modified it will recompile and cache the new version.

For included/required files APC prefers the use of absolute paths as for relative path includes (any path that doesn’t start with / on Unix) APC has to check in order to uniquely identify the file. If you use absolute path includes APC can skip the stat and use that absolute path as the unique identifier for the file.

You can read more about APC configuration parameters at http://php.net/manual/en/apc.configuration.php

Comments

Leave a Comment

Back to top