asyncapi / generator

Use your AsyncAPI definition to generate literally anything. Markdown documentation, Node.js code, HTML documentation, anything!
https://asyncapi.com/docs/tools/generator
Apache License 2.0
772 stars 235 forks source link

[BUG] Generation failing with `Generator Error: Installation failed` #1256

Closed talglobus closed 3 months ago

talglobus commented 3 months ago

Describe the bug.

Whenever I try to generate anything, I get Generator Error: Installation failed

Here's an example I tried from the website:

asyncapi generate fromTemplate https://bit.ly/asyncapi @asyncapi/html-template -o example
┌  AsyncAPI Generator
│
◇  Generation failed
Generator Error: Installation failed

Expected behavior

Generations work correctly

Screenshots

Screenshot 2024-08-17 at 6 08 19 PM

How to Reproduce

  1. Install asyncapi with bun
  2. $ asyncapi generate fromTemplate https://bit.ly/asyncapi @asyncapi/html-template -o example
  3. Use ^+C (Mac) to quit in the middle of the generate operation
  4. Try generating anything and observe error

Note I've uninstalled and reinstalled the CLI multiple times since and found the error to be durable

🥦 Browser

Google Chrome

👀 Have you checked for similar open issues?

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

None

github-actions[bot] commented 3 months ago

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

Gmin2 commented 3 months ago

It is working fine in my machine, can you share a screen recording of it @talglobus

derberg commented 3 months ago

please run generation with --debug flag and share the log

bjhartin commented 3 months ago

Happens for me too, on multiple projects. Did not happen before, so I suspect this has to do with a new version of a template or something.

Debug log is:

AsyncAPI anonymously tracks command executions to improve the specification and tools, ensuring no sensitive data reaches our servers. It aids in comprehending how AsyncAPI tools are used and adopted, facilitating ongoing improvements to our specifications and tools.

To disable tracking, please run the following command:
  asyncapi config analytics --disable

Once disabled, if you want to enable tracking back again then run:
  asyncapi config analytics --enable

┌  AsyncAPI Generator
│
Template is not available locally and expected location is undefined. Known details are: undefined Error: Cannot find module '@asyncapi/html-template/package.json'
Require stack:
- /usr/local/lib/node_modules/noop.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
    at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (/usr/local/lib/node_modules/@asyncapi/cli/node_modules/@cspotcode/source-map-support/source-map-support.js:811:30)
    at resolveFileName (/usr/local/lib/node_modules/@asyncapi/cli/node_modules/resolve-from/index.js:29:39)
    at resolveFrom (/usr/local/lib/node_modules/@asyncapi/cli/node_modules/resolve-from/index.js:43:9)
    at module.exports (/usr/local/lib/node_modules/@asyncapi/cli/node_modules/resolve-from/index.js:46:47)
    at utils.getTemplateDetails (/usr/local/lib/node_modules/@asyncapi/cli/node_modules/@asyncapi/generator/lib/utils.js:196:30)
    at Generator.installTemplate (/usr/local/lib/node_modules/@asyncapi/cli/node_modules/@asyncapi/generator/lib/generator.js:561:24)
    at Generator.installAndSetupTemplate (/usr/local/lib/node_modules/@asyncapi/cli/node_modules/@asyncapi/generator/lib/generator.js:283:73)
    at Generator.generate (/usr/local/lib/node_modules/@asyncapi/cli/node_modules/@asyncapi/generator/lib/generator.js:196:16)
    at async Generator.generateFromString (/usr/local/lib/node_modules/@asyncapi/cli/node_modules/@asyncapi/generator/lib/generator.js:444:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/usr/local/lib/node_modules/noop.js' ]
}
Template installation started because the template cannot be found on disk.
Using npm registry https://registry.npmjs.org and authorization type anonymous to handle template installation.
◇  Generation failed
Generator Error: Installation failed
bjhartin commented 3 months ago

It appears this bug was introduced in 2.3.12 of the html template. I don't have this problem with versions prior to that, going back to 2.3.8. So, pinning the version in the template is a solution, e.g. @asyncapi/html-template@2.3.11. FYI @talglobus.

bjhartin commented 3 months ago

I should mention I'm using the docker image 'asyncapi/cli' at tag 'c03a2a76e1e4' to perform the generation via:

# Has the problem using template 2.3.12
docker run --user=root \
   --rm \
   -v "$VOLUME_MAPPING" \
   -v ${PWD}/output:"$OUTPUT_FOLDER_IN_CONTAINER" \
   asyncapi/cli generate fromTemplate \
   -o "$OUTPUT_FOLDER_IN_CONTAINER" \
   "$DOC_IN_CONTAINER" \
   @asyncapi/html-template@2.3.12 \
   --force-write \
   -p sidebarOrganization=byTagsNoRoot
derberg commented 3 months ago

sorry about that, fix has been deployed -> https://github.com/asyncapi/html-template/pull/672#issuecomment-2324913576 thanks for letting us know