DiagnoticRun.php error

Version 7.11.15
Sugar Version 6.5.25 (Build 344)

When I run the Admin Diagnostic tool. I get the following error…

Warning : opendir(cache/diagnostic/8e07d262-364f-7ec1-9dac-5f06553f4b3c/diagnostic20200708-232320/): failed to open dir: No such file or directory in /home/pos/public_html/crm/modules/Administration/DiagnosticRun.php on line 256

The file exists, so I checked line 256 and it’s highlighted below

// Deletes the directory recursively
function deleteDir($dir)
if (substr($dir, strlen($dir)-1, 1) != ‘/’) {
$dir .= ‘/’;

**if ($handle = opendir($dir)) {**   <-----Line 256
    while ($obj = readdir($handle)) {
        if ($obj != '.' && $obj != '..') {
            if (is_dir($dir.$obj)) {
                if (!deleteDir($dir.$obj)) {
                    return false;
            } elseif (is_file($dir.$obj)) {
                if (!unlink($dir.$obj)) {
                    return false;

What it is trying to do is delete the “cache” directory, or something under that directory. It’s likely just finishing off the job, trying to delete the directories and the files that the diagnostic run itself creates.

So I would guess that your problem is a bit before - it probably failed to create the files or directories, and that’s why they can’t be found later.

1 Like

Extra idea: if you try setting only one checkbox at a time, you can figure out exactly which of the Diagnostic parts is causing trouble.

1 Like

Thanks, I tried your tip about trying 1 at a time, every single one of them produced an error. It is creating directories with zip files in them in the /cache/diagnostic/ folder. But the zip files have permission of 644 which can be the source of the problem.

You need to check not only permissions, but also ownerships of those directories. They need to be owned by the same user that your web server is running under (for example, in Ubuntu, www-data).

The security settings of newly created directories are derived from the parent directory, according to what permissions it has, who owns it, and the state of the SetUID and SetGID bits.

After looking at it again, I see it looks like it’s actually working, but there is a second part that is failing. This happens on every checkbox

You shouldn’t be echoing your errors on screen. You can fix this by setting dysplay_errors to Off in your php.ini and restarting web server.

Then you can track messages in the log files. If you don’t experience any functionality problems, ignore the messages unless they’re FATAL or ERROR level.

That did it! Resolved two issues actually.

1 Like