[FOLIO-1370] Platforms fail to install on Windows (platform-core, folio-testing-platform) Created: 23/Jul/18  Updated: 11/Dec/18  Resolved: 11/Dec/18

Status: Closed
Project: FOLIO
Components: None
Affects versions: None
Fix versions: None

Type: Bug Priority: P3
Reporter: Matthew Jones Assignee: Matthew Jones
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original estimate: Not Specified

Issue links:
Relates
relates to FOLIO-1344 use stripes-cli in the build and test... Closed
Sprint:

 Description   

Platforms containing the postinstall script build-module-descriptors.js fail on Windows development environments when included in a yarn workspace.

The following error is from a small workspace install (users, inventory, stripes-core, folio-testing-platform):

Exit code: 1
Command: node ./build-module-descriptors.js
Arguments:
Directory: C:\Users\mattjones\projects\folio\tempworkspace4\node_modules\@folio\folio-testing-platform
Output:
* build-module-descriptors
C:\Users\mattjones\projects\folio\tempworkspace4\node_modules\@folio\folio-testing-platform\build-module-descriptors.js: cannot scan 'C:\Users\mattjones\projects\folio\tempworkspace4\node_modules\@folio\node_modules\@folio': ENOENT: no such file or directory, scandir 'C:\Users\mattjones\projects\folio\tempworkspace4\node_modules\@folio\node_modules\@folio'

    at ChildProcess.exithandler (child_process.js:291:12)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:961:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5) killed: false, code: 1, signal: null, cmd: 'yarn' }

Error from a large workspace install (all available modules):

error C:\Users\mattjones\projects\folio\tempworkspace5all\node_modules\@folio\platform-core: Command failed.
Exit code: 2
Command: node ./build-module-descriptors.js
Arguments:
Directory: C:\Users\mattjones\projects\folio\tempworkspace5all\node_modules\@folio\platform-core
Output:
* build-module-descriptors
processing 'eslint-config-stripes'
C:\Users\mattjones\projects\folio\tempworkspace5all\node_modules\@folio\platform-core\build-module-descriptors.js: cannot run 'node node_modules/@folio/stripes-core/util/package2md.js node_modules/@folio/eslint-config-stripes/package.json > ModuleDescriptors/eslint-config-stripes.json': { Error: Command failed: node node_modules/@folio/stripes-core/util/package2md.js node_modules/@folio/eslint-config-stripes/package.json > ModuleDescriptors/eslint-config-stripes.json
internal/modules/cjs/loader.js:596
    throw err;
    ^

Error: Cannot find module 'C:\Users\mattjones\projects\folio\tempworkspace5all\node_modules\@folio\platform-core\node_modules\@folio\stripes-core\util\package2md.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
    at Function.Module._load (internal/modules/cjs/loader.js:520:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
    at startup (internal/bootstrap/node.js:238:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:572:3)

    at checkExecSyncError (child_process.js:603:11)
    at Object.execSync (child_process.js:640:13)
    at fs.readdir (C:\Users\mattjones\projects\folio\tempworkspace5all\platform-core\build-module-descriptors.js:30:35)
    at FSReqWrap.oncomplete (fs.js:169:20)
  status: 1,
  signal: null,
  output:
   [ null,
     <Buffer >,
     <Buffer 69 6e 74 65 72 6e 61 6c 2f 6d 6f 64 75 6c 65 73 2f 63 6a 73 2f 6c 6f 61 64 65 72 2e 6a 73 3a 35 39 36 0d 0a 20 20 20 20 74 68 72 6f 77 20 65 72 72 3b ... > ],
  pid: 1040,
  stdout: <Buffer >,
  stderr:
   <Buffer 69 6e 74 65 72 6e 61 6c 2f 6d 6f 64 75 6c 65 73 2f 63 6a 73 2f 6c 6f 61 64 65 72 2e 6a 73 3a 35 39 36 0d 0a 20 20 20 20 74 68 72 6f 77 20 65 72 72 3b ... > }
internal/modules/cjs/loader.js:596
    throw err;
    ^

Error: Cannot find module 'C:\Users\mattjones\projects\folio\tempworkspace5all\node_modules\@folio\platform-core\node_modules\@folio\stripes-core\util\package2md.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
    at Function.Module._load (internal/modules/cjs/loader.js:520:25)


 Comments   
Comment by Matthew Jones [ 23/Jul/18 ]

Some short-term workarounds:

(a) Don't select platform-core and folio-testing-platform while running stripes workspace

(b) If those platforms are needed, bypass their install scripts. This can be done by deferring the yarn install, by running stripes workspace with the --no-install option. Following the workspace command, manually disable the postinstall scripts found in platform-core and folio-testing-platform. This can be done by renaming "postinstall" to anything else. Finally perfrorm a yarn install from the workspace directory.

(c) If the module descriptors from build-module-descriptors are also needed, perform workaround (b) and run stripes mod descriptor --configFile stripes.config.js from within the platform.

Comment by Matthew Jones [ 23/Jul/18 ]

The overall issue appears to be a result of hard-coded paths within build-module-descriptors.js that are non-workspace and/or non-Windows friendly. The following solutions come to mind:

(d) Permanently disable the postinstall script, by renaming it so it doesn't automatically run with every install. Then manually invoke the script as needed by Jenkins. Eventually this would be followed by (e) or (f) below.

(e) Update and maintain build-module-descriptors.js to be cross-platform and/or workspace friendly. This will likely involve a couple path tweaks to the existing command.

(f) Retire build-module-descriptors.js replacing it with the CLI's mod descriptor command that is cross-platform. I'm inclined to go this route to consolidate code, however, one notable difference is the CLI outputs an array of module descriptors rather than separate files for each. Therefore added work may be necessary in the CLI or Jenkins to fully support this option.

Given "platform-*" replaces "folio-testing-platform", perhaps we start by implementing (d) on platform-core, leaving folio-testing-platform alone. I can then omit folio-testing-platform from the "stripes workspace" command, promoting platform-* in its place.

John Malconian, Any thoughts? Does diverging "platform-core" from "folio-testing-platform" further complicate things in CI given the outstanding testing issues?

Comment by John Malconian [ 23/Jul/18 ]

I like your plan, particularly option (f). We can work around the json array of MDs issue. Retiring build-module-descriptors.js would also resolve the issue of generating module descriptors for @folio dependencies that are not modules.

I've renamed 'postinstall' in platform-core to 'generate-mod-descriptors' and updated the CI to run 'yarn generate-mod-descriptors --strict' for any platform except folio-testing-platform which will continue to execute 'yarn postinstall --strict'.

Comment by Matthew Jones [ 11/Dec/18 ]

Closing this issue because platform-core/complete have previously been resolved and folio-testing-platform has since been deprecated in favor of platform-complete's snapshot branch. Folio-testing-platform has been removed from selection in the CLI workspace command as well.

Generated at Thu Feb 08 23:12:50 UTC 2024 using Jira 1001.0.0-SNAPSHOT#100246-sha1:7a5c50119eb0633d306e14180817ddef5e80c75d.