Announcement

Collapse
No announcement yet.

Error when creating a custom extension

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error when creating a custom extension

    I'm trying to create a custom extension using this guide: https://github.com/espocrm/ext-template

    I'm following the steps, but when I get to `node build --all​` I get the following error:

    Code:
    Fetching EspoCRM repository...
      Downloading EspoCRM archive from Github...
      Unzipping...
    Installing EspoCRM instance...
      Creating config...
      Npm install...
      Building...
      Install: step1...
      Install: setupConfirmation...
      Install: checkPermission...
      Install: saveSettings...
      Install: buildDatabase...
      Install: createUser...
      Install: finish...
      Merge configs...
    node:child_process:826
        err = new Error(msg);
              ^
    
    Error: Command failed: php merge_configs.php
        at checkExecSyncError (node:child_process:826:11)
        at Object.execSync (node:child_process:900:15)
        at /Applications/MAMP/htdocs/ext-procore/build.js:175:12
        at new Promise (<anonymous>)
        at install (/Applications/MAMP/htdocs/ext-procore/build.js:118:12)
        at /Applications/MAMP/htdocs/ext-procore/build.js:16:17 {
      status: 255,
      signal: null,
      output: [ null, Buffer(0) [Uint8Array] [], Buffer(0) [Uint8Array] [] ],
      pid: 72775,
      stdout: Buffer(0) [Uint8Array] [],
      stderr: Buffer(0) [Uint8Array] []
    }​
    I'm not really clear what this error means (I even asked ChatGPT ;-)) or how to start troubleshooting it. I'm on MacOS 13, M1 Silicon, using PHP 8.2.0, Node 16.9, and NPM 8.19.2. I'm running latest MAMP (6.8). I don't mind debugging, but I'm not even sure where to start...or if there's a configuration somewhere I might need to revisit that isn't documented or obvious.

  • #2
    I seem to have got it sorted? I am able to access my instance, but still get this error:

    Code:
    Fetching EspoCRM repository...
      Downloading EspoCRM archive from Github...
      Unzipping...
    Installing EspoCRM instance...
      Creating config...
      Npm install...
      Building...
      Install: step1...
      Install: setupConfirmation...
      Install: checkPermission...
      Install: saveSettings...
      Install: buildDatabase...
      Install: createUser...
      Install: finish...
      Merge configs...
    node:internal/errors:464
        ErrorCaptureStackTrace(err);
        ^
    
    <ref *1> Error: spawnSync /bin/sh ENOBUFS
        at Object.spawnSync (node:internal/child_process:1083:20)
        at spawnSync (node:child_process:812:24)
        at Object.execSync (node:child_process:895:15)
        at /Applications/MAMP/htdocs/ext-procore/build.js:175:12
        at new Promise (<anonymous>)
        at install (/Applications/MAMP/htdocs/ext-procore/build.js:118:12)
        at /Applications/MAMP/htdocs/ext-procore/build.js:16:17 {
      errno: -55,
      code: 'ENOBUFS',
      syscall: 'spawnSync /bin/sh',
      path: '/bin/sh',
      spawnargs: [ '-c', 'php merge_configs.php' ],
      error: [Circular *1],
      status: null,
      signal: 'SIGTERM',
      output: [
        null,
        Buffer(1048721) [Uint8Array] [
          111,  98, 106, 101,  99, 116,  40,  69, 115, 112, 111,  92,
           67, 111, 114, 101,  92,  65, 112, 112, 108, 105,  99,  97,
          116, 105, 111, 110,  41,  35,  50,  32,  40,  49,  41,  32,
          123,  10,  32,  32,  91,  34,  99, 111, 110, 116,  97, 105,
          110, 101, 114,  34,  58, 112, 114, 111, 116, 101,  99, 116,
          101, 100,  93,  61,  62,  10,  32,  32, 111,  98, 106, 101,
           99, 116,  40,  69, 115, 112, 111,  92,  67, 111, 114, 101,
           92,  67, 111, 110, 116,  97, 105, 110, 101, 114,  41,  35,
           50,  52,  32,  40,
          ... 1048621 more items
        ],
        Buffer(0) [Uint8Array] []
      ],
      pid: 84350,
      stdout: Buffer(1048721) [Uint8Array] [
        111,  98, 106, 101,  99, 116,  40,  69, 115, 112, 111,  92,
         67, 111, 114, 101,  92,  65, 112, 112, 108, 105,  99,  97,
        116, 105, 111, 110,  41,  35,  50,  32,  40,  49,  41,  32,
        123,  10,  32,  32,  91,  34,  99, 111, 110, 116,  97, 105,
        110, 101, 114,  34,  58, 112, 114, 111, 116, 101,  99, 116,
        101, 100,  93,  61,  62,  10,  32,  32, 111,  98, 106, 101,
         99, 116,  40,  69, 115, 112, 111,  92,  67, 111, 114, 101,
         92,  67, 111, 110, 116,  97, 105, 110, 101, 114,  41,  35,
         50,  52,  32,  40,
        ... 1048621 more items
      ],
      stderr: Buffer(0) [Uint8Array] []
    }​
    There was an issue with database credentials that got me out of the previous error and into this one. But at least this seems workable...

    Comment


    • jflores
      jflores commented
      Editing a comment
      I was able to resolve the error by changing clearing out the "config.php" in the "https://github.com/espocrm/ext-template#config-for-espocrm-instance" part of the instruction.

      If there is NO config.php file, then it will throw an error.

      However, if you use the example provided in the documentation:

      <?php
      return [
      'useCacheInDeveloperMode' => true,
      ];

      Then you also get an error because "useCacheInDeveloperMode" is no longer an attribute in the config.php array. So, either create a config.php with just:

      <?php

      so it doesn't through an error OR make sure you are using attributes that are part of the new config.php array.

      I havent' tested with config-internal.php, but presumably that would also transfer?...

  • #3
    I suggest you use an actual working free extension instead of the template since the template need to make edit for it to work. Whereas a free extension is already working.

    If you modified that and debug it from there I think you learn more... But this is all theory talk, I can't code at all...

    Comment


    • #4
      I don't have experience with the template/installer but have created several custom extensions which work fine, without using it.

      My understanding is that the template automates the creation of directories and scripts required by an extension, which can be a great time saver, but the actual result is exactly the same as if you had created the extension manually.

      If you have not created any custom extensions before, I would suggest that you learn first how an extension is structured by downloading and analyzing the free Real Estate extension. It is a great working example, and the knowledge that you will gain about how things are structured and work within a module will surely outweigh any time saved by creating at least your first extension by hand.
      Last edited by telecastg; 04-29-2023, 11:19 PM.

      Comment


      • jflores
        jflores commented
        Editing a comment
        Thanks! I had initially started with using the more 'manual' approach and felt like the workflow was kind of clumsy. The automation of scripts and directories is what I was trying out, in order to save time and reduce (my) likelihood of making mistakes. Previously, everything I did was in the custom directory and then I'd copy it to a module.

        The problem was that then I'd go make some changes in the Entity Manager, it would create more files in the 'custom' directory and then I'd have to manually copy them back to the module. More than once, I'd forget to copy something and then have to go back and forth troubleshooting and copying. Not the worst thing in the world, but not efficient.

        Curious your development workflow (if you're willing to share it).

    • #5
      Yes of course, I think that my workflow is very similar to what you described.

      Generally I start with a pretty good idea of what I want to accomplish but a rather fuzzy idea of how to actually implement the functionality desired, so the first step is to use the Entity Manager and the Layout Manager to create the core entities, links and layouts that I think will be needed (almost like scaffolding) and then transfer everything from the custom namespaces (front end and back end) to module namespaces.

      Aside from moving folders physically to module namespaces, for php classes I adjust the namespace declaration to match the new physical location and for view classes, I replace the "custom:" namespace designation with "my-module:" namespace designation, and then go to the configuration (metadata) json scripts to make sure that the correct module reference is used there as well.

      After this initial transfer, I start writing code to accomplish my original goals, so any additional php classes or javascript views are stored in the module namespaces.

      Inevitably there will be a need to create or modify an entity, link or layout, and for that, I go back to the Entity Manager and Layout Manager, make the changes there and repeat the transfer.

      There are instances where the work required to do the above changes manually is less than the work required to transfer the GUI generated changes from custom to module, so in such cases I just edit the corresponding files by hand.

      As a hint: If you organize all your customizations in functional modules, instead of dumping everything in the custom namespace, it will be a lot easier to transfer new customizations because the custom namespace will be empty, except for the new GUI generated scripts .

      Long time ago I suggested to the developers, that they allow Users to define a module every time a GUI customization was made, but I never got a reply, so I assume that they were not interested.

      I don't know if the use of the template / installer addresses that point or just organizes the initial customizations, which in my case is normally a not significant time saver, since the initial GUI customization is only the "first draft" of what I hope to accomplish with an extension.
      Last edited by telecastg; 04-29-2023, 10:54 PM.

      Comment


      • esforim
        esforim commented
        Editing a comment
        Do an issue request on Git telecastg! Or maybe you did?

        Yuri clean down from like few hundreds outstanding Issue to only about 130 at the moment.

        If he reject it at least now there is 'something' to go back to.
    Working...
    X