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).

01PHP Warning:  include(): realpath failed to canonicalize Mage/Core/Model/App.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93
02 
03PHP Warning:  include(): realpath failed to canonicalize Varien/Event/Collection.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93
04 
05PHP Warning:  include(): realpath failed to canonicalize Varien/Event/Observer/Collection.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93
06 
07PHP Warning:  include(): realpath failed to canonicalize Mage/Core/Model/Config.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93
08 
09PHP Warning:  include(): realpath failed to canonicalize Mage/Core/Model/Config/Base.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93
10 
11PHP Warning:  include(): realpath failed to canonicalize Varien/Simplexml/Config.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93
12 
13PHP Warning:  include(): realpath failed to canonicalize Mage/Core/Model/Config/Options.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93
14 
15PHP Warning:  include(): realpath failed to canonicalize Varien/Object.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93
16 
17PHP Warning:  include(): realpath failed to canonicalize Varien/Profiler.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93
18 
19PHP Warning:  include(): realpath failed to canonicalize Zend/Log.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93
20 
21PHP Warning:  include(): realpath failed to canonicalize Mage/Core/Model/Store/Exception.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93
22 
23PHP Warning:  include(): realpath failed to canonicalize Mage/Core/Exception.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93
24 
25PHP Warning:  include(): realpath failed to canonicalize Zend/Log/Formatter/Simple.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93
26 
27PHP Warning:  include(): realpath failed to canonicalize Zend/Log/Formatter/Interface.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93
28 
29PHP Warning:  include(): realpath failed to canonicalize Zend/Log/Writer/Stream.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93
30 
31PHP Warning:  include(): realpath failed to canonicalize Zend/Log/Writer/Abstract.php - bailing in /var/www/magentoproject/lib/Varien/Autoload.php on line 93
32 
33PHP 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

01[APC]
02 
03extension=apc.so
04apc.enabled =1
05apc.shm_segments = 1
06apc.shm_size = 512M
07apc.ttl = 7200
08apc.user_ttl  = 7200
09apc.num_files_hint = 1024
10apc.mmap_file_mask = /tmp/apc.XXXXXX
11apc.enable_cli = 1
12apc.cache_by_default  = 1
13apc.max_file_size = 10M
14apc.stat = 0

I changed ‘apc.stat’ from

1apc.stat=0

to

1apc.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

Leave a Comment

Comments

Back to top