Pages

Wednesday, September 21, 2011

SugarCRM Troubleshooting: Error Deploying Custom Modules

SugarCRM administrators that have utilized the Module Builder tool are likely to have run into this scenario on more than one occasion....

A custom module is created and you proceed to click the Deploy button. 

The deployment process initiates and appears to be working as expected, but suddenly, the following error message is displayed:


"An error has occured during deploy process, you package may not have installed correctly."

Does it seem familiar to you? 

It happened to me for the first time some months back, ironically, not long after attending the yearly SugarCON event where I had attended an in-depth discussion on the mechanics of the Module Builder tool. This experience became important because it helped explained the error and eventually led me to the solution, which we will now discuss.


The condensed version of the explanation is that the deploy process creates a package similar to those used by the Module Loader tool (including a manifest.php file) and then the Module Builder tool triggers the code in SugarCRM which normally executes were one to install a package via the Module Loader tool. In turn, this code processes the package created by the Module Builder and the custom module is installed.

After giving this some thought, it dawned on me that the likely source of the error at hand was rooted in the Module Loader tool.

Upon inspecting Module Loader, its related database table (upgrade_history) and the contents of the <sugar_root>/cache/upload directory, a discrepancy became apparent.

In short, there were entries in the upgrade_history table -- and in turn, in the installed extensions section of the Module Loader screen -- which did not actually have their corresponding files in the <sugar_root>/cache/upload directory, as they should. 

Under normal circumstances, all packages installed via the Module Loader end up in the <sugar_root>/cache/upload directory, as was explained in the discussion about the Module Builder mechanics.

Editing the upgrade_history table to remove the record pertaining to the Module Loader package with the missing files in cache/upload resolves the problem. Try re-deploying the custom module after making that change to the database and see if that corrects it.

Another potential solution relates to having entries of the custom module one is attempting to deploy already listed on the bottom pane of the Module Loader screen. Removing those entries via the Delete Package button prior to deploying the custom module will usually resolve the matter.

17 comments:

  1. looks like you know what you're doing but i can't follow your instructions. i'm lost at the last part of
    Editing the upgrade_history table to remove the record pertaining to the Module Loader package......
    i have no idea what you're talking about and how to get this error fixed on my installation. if i delete teh custom module and re create it it deploy fine but after some changes to fields deployment failed an dgives me the same error you're talking about. any help for dummies...

    ReplyDelete
  2. @Smaqsood

    The part you reference relates to directly manipulating the database, more specifically, the upgrades_history table within your SugarCRM database.

    To do that, you need a MySQL administration tool such as SQLyog, phpMyAdmin, or Navicat. If you are using Microsoft SQL, you will need to use MS SQL Server Management Studio.

    If you are unfamiliar with these tools, you should consider hiring someone to help you as you can cause some serious damage to your database.

    ReplyDelete
  3. Kind of a separate note but how do you troubleshoot module loader for On-Demand installs? I have a very simple language extension that I'm trying to copy from my folder to a directory and it's saying it couldn't copy the file. Also, what do you recommend for extending a language. I uploaded a custom project dashlet and just need to add the mod that sets the label so when I select it in Add Dashlet it says Project.

    ReplyDelete
    Replies
    1. It is a bit difficult due to all the restrictions imposed on one, but one thing I've done in the past is use the database admin trick I describe in the following post to clean up the upgrade_history table:

      http://cheleguanaco.blogspot.com/2012/01/database-administration-redux.html

      If you are using On-Demand, you are probably better off submitting a ticket to SugarCRM support for that matter though, as attempting to troubleshoot it on your own will be frustrating due to the limited access.

      As for the dashlet, its been a while since I've looked at that, but if memory serves me, the definition of the dashlet should already include a place for the title you are speaking of.

      Delete
  4. At a total loss of your explanation. Could you try something along the lines of an enumerated instruction set? Or maybe an example. That usually helps.

    ReplyDelete
    Replies
    1. I am assuming you need help with this part?

      "Editing the upgrade_history table to remove the record pertaining to the Module Loader package with the missing files in cache/upload resolves the problem. Try re-deploying the custom module after making that change to the database and see if that corrects it."

      Where in the edit process of that table are you stuck?

      Delete
  5. I have a similar question.. however, I have no cache/upload folder so I am confused as to where to go from here.

    ReplyDelete
    Replies
    1. Newer versions of Sugar use a slightly different directory structure. Take a look at /upload instead.

      Delete
  6. I'm not sure where to continue from here, or if this folder is really the issue. When I try to deploy my custom package from Module Builder, the deploy fails as you described above, and then another page loads with stack traces and the following two warnings:

    Warning: include(cache/modules/ProjectResources/ProjectResourcevardefs.php) [a href='function.include function.include]: failed to open stream: Permission denied in C:\wamp\www\sugarcrm\include\SugarObjects\VardefManager.php on line 162

    Warning: include() [function.include]: Failed opening 'cache/modules/ProjectResources/ProjectResourcevardefs.php' for inclusion (include_path='C:\wamp\www\sugarcrm\include\HTMLPurifier/standalone;C:\wamp\www\sugarcrm\include/..;.;C:\php\pear') in C:\wamp\www\sugarcrm\include\SugarObjects\VardefManager.php on line 162

    Any further information you could provide me would be greatly appreciated. I read another blog you posted about this issue and have enabled my zlib compression. This sugarcrm instance is hosted on the WAMP server

    ReplyDelete
    Replies
    1. That doesn't look like an issue related to the folder. Note the first error indicates a Permission Denied message. That would seem to be more indicative of a problems with permissions for the web user on that server.

      Delete
  7. I have this warning: "Your PHP configuration must be changed to allow files of at least 6MB to be uploaded. Please modify the upload_max_filesize value in your php.ini located at: C:\xampp\php\php.ini" I have edited and save it to 6MB, however, I am still unable to deploy my module and the error still appears.

    ReplyDelete
    Replies
    1. You should set that value to 40MB or higher. 6MB will not be sufficient.

      Delete
    2. i set it to 40MB but the errror still persist..any ideas to why the error still persist?

      Delete
    3. There is another related setting called "post_max_size" which should also be set to 40M or higher. Use phpinfo() to verify that the settings have been applied.

      Delete
  8. This comment has been removed by the author.

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. Angel, thanks for this post, it was really helpful to me (In fact, it saved my job today ;) ). Also, I want to ask you for a post that explains how the Module Builder works (if possible). Again, thanks a lot

    ReplyDelete

Your comments, feedback and suggestions are welcome, but please refrain from using offensive language and/or berating others. Thank you in advance.