sugar_file_utils.php Fatal error: on migrating SugarCRM

[text]Fatal error: sugar_file_put_contents_atomic() : fatal rename failure ‘/tmp/tempI3QakJ’ -> ‘cache/modules/Employees/Employeevardefs.php’ in /home/account_name/public_html/sugarcrm/include/utils/sugar_file_utils.php on line 187
[/text]

It’s a permissions thing. Setting up a new server to migrate SugarCRM. The new install of Sugar appears ok until I update the config.php file and then it breaks.

The trigger is the permissions on the second named file

[text]
‘cache/modules/Employees/Employeevardefs.php’
[/text]

Just for clarity the line 187 that is referenced is in this function in SugarCRM

[php]
180 if (!@rename($temp, $filename))
181 {
182 @unlink($filename);
183 if (!@rename($temp, $filename))
184 {
185 // cleaning up temp file to avoid filling up temp dir
186 @unlink($temp);
187 trigger_error("sugar_file_put_contents_atomic() : fatal rename failure ‘$temp’ -> ‘$filename’", E_USER_ERROR);
188 }
189 }
[/php]

The error is triggered when line 183 fails to rename the temp file as the cache file. Permissions on the temp directory must be ok or the creation of the temp file would have triggered an earlier error. It is also unlinked (deleted) successfully which means that at line 186 the temp directory/file permissions are ok. So it must be the cache directory at issue.

In this case the cpanel server was allocating the user account as both owner and group. Sugar apparently wants to see Apache as the group, or at least the Apache account owner, ‘nobody’. So while the chmod settings for owner and group read/write were ok, the group was incorrect.

[text]
#chown -R owner:nobody sugarcrm/
[/text]

Command for the ownership change for the group to nobody.

Edit: As correctly pointed out I had used chmod when I manually typed up the instructions. Corrected the above to read chown. Thanks Derek.

One reply

Leave a Reply

Your email address will not be published. Required fields are marked *