Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to install with rush/pnpm due to upstream dependency bug #905

Closed
robbieaverill opened this issue Aug 5, 2024 · 8 comments
Closed
Labels
bug Something isn't working

Comments

@robbieaverill
Copy link
Contributor

Describe the bug

When I try to install this package into a Docusaurus site that uses rush/pnpm as the package manager, I am unable to.

This is causes by an upstream bug in postman-code-generators: postmanlabs/postman-code-generators#760. I'm raising it here in case others are experiencing the same issue, but also in case there's a solution to avoid the issue in this package.

I don't actually want any generated code examples at all. It's a shame that I can't use this package without them.

Expected behavior

I should be able to install the package.

Current behavior

$ pnpm install

...
node_modules/.pnpm/[email protected]/node_modules/postman-code-generators: Running postinstanode_modules/.pnpm/[email protected]/node_modules/postman-code-generators: Running postinstall script, failed in 920ms
.../node_modules/postman-code-generators postinstall$ node npm/deepinstall.js
│ Detected package manager: pnpm
│ Running pre-package script
│ Run successful languages.js saved in lib/assets
│ csharp-httpclient: pnpm install --no-audit --production
│ Failed to run pnpm install on codegen csharp-httpclient, here is the error:
│ csharp-restsharp: pnpm install --no-audit --production
│ Failed to run pnpm install on codegen csharp-restsharp, here is the error:
│ .../common/temp/node_modules/.pnpm/[email protected]/node_modules/a…
│             if (fn === null) throw new Error("Callback was already called.");
│                                    ^
│ Error: Callback was already called.
│     at .../common/temp/node_modules/.pnpm/[email protected]/node_mo…
│     at .../common/temp/node_modules/.pnpm/[email protected]/node_mo…
│     at .../common/temp/node_modules/.pnpm/postman-code-genera…
│     at Array.forEach (<anonymous>)
│     at .../common/temp/node_modules/.pnpm/postman-code-genera…
│     at .../common/temp/node_modules/.pnpm/[email protected]/node_mo…
│     at replenish (.../common/temp/node_modules/.pnpm/async@3.…
│     at iterateeCallback (.../common/temp/node_modules/.pnpm/a…
│     at .../common/temp/node_modules/.pnpm/[email protected]/node_mo…
│     at .../common/temp/node_modules/.pnpm/[email protected]/node_mo…
│ Node.js v20.11.0
└─ Failed in 921ms at .../common/temp/node_modules/.pnpm/[email protected]/node_modules/postman-code-generators
 ELIFECYCLE  Command failed with exit code 1.

Possible solution

Make the code-generators package opt-in.

Your Environment

  • Version used: 3.0.1
  • Environment name and version: Node 20.11.0
  • Operating System and version (desktop or mobile): Mac M1
@robbieaverill robbieaverill added the bug Something isn't working label Aug 5, 2024
@lpicchi
Copy link

lpicchi commented Aug 7, 2024

Workaround till they fix this:

  "resolutions": {
    "postman-code-generators": "1.10.1"
  },

@robbieaverill
Copy link
Contributor Author

Thanks @lpicchi. I have 1.12.0 installed - is a downgrade necessary?

github-merge-queue bot pushed a commit to immersve/immersve-docs that referenced this issue Aug 8, 2024
I encountered a problem with sidebar generation while working on:
- #406

Upgrading the package fixed it. However, there is an issue with the
latest version of the package:
PaloAltoNetworks/docusaurus-openapi-docs#905,
which is why I pinned the version of `postman-code-generators`

Ticket Link: #406

<!-- See
https://www.notion.so/immersve/Pull-Request-Checklist-72c856d319e24396aa82179e8894face
(delete this comment before creating PR) -->
@lpicchi
Copy link

lpicchi commented Aug 8, 2024

@robbieaverill I don't have any knowledge on rush.js but according to their docs it supports a "globalOverrides" config. You should use it to set the package to the mentioned "safe" version.

https://rushjs.io/pages/configs/pnpm-config_json/

@robbieaverill
Copy link
Contributor Author

robbieaverill commented Aug 8, 2024

Using version 1.10.1 will not work entirely for Rush/pnpm users, because prior to 1.11.0 postman-code-generators was not using your package manager when performing deep installs. See postmanlabs/postman-code-generators#744.

It might work for users without NPM registry authorization, or those using npm directly.

@lpicchi
Copy link

lpicchi commented Aug 8, 2024

I'm sorry to hear that... it seems there is no workaround for your use case then

@robbieaverill
Copy link
Contributor Author

After trying again, I can confirm that 1.10.1 installs locally without this error. Unfortunately, another issue presents. The dependency's deep-install process tries to install using the wrong package manager, which doesn't share the same auth as my Rush setup. This was fixed in postmanlabs/postman-code-generators#744, but the combination of both bugs still makes this dependency unusable in this context.

@robbieaverill
Copy link
Contributor Author

robbieaverill commented Aug 20, 2024

In case it is useful to anyone, when using Rush and finding build errors due to NPM repository authorization issues in CI (when deep installing postman-code-generators), I did the following as a workaround:

  • Accept that I don't want or need the code snippets and I am happy to remove them
  • Replace postman-code-generators with an empty package using globalOverrides to force install of a local, stub library
    • Example is configured as libraries/temp/postman-code-generators with a stub package.json and other necessary files
  • Swizzle the ApiExplorer/index file into my project
  • Remove the CodeSnippets component from it, which appears to be the only place referencing postman-code-generators

Swizzled file:

// File: src/theme/ApiExplorer/index.jsx
import React from 'react';
import Request from '@theme/ApiExplorer/Request';
import Response from '@theme/ApiExplorer/Response';

export default ({ item }) => (
    <>
        <Request item={item} />
        <Response item={item} />
    </>
);

Note that I had a hard time getting TypeScript configuration to appreciate this new file. I raised an issue for that as #920 and proceeded to swizzle it as a JavaScript file instead.

Edit: after doing this, I ran into another problem: #920. I've ended up forking the theme.

@robbieaverill
Copy link
Contributor Author

This should be fixed by updating postman-code-generators to v1.13.0 or newer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants