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

Seems to be broken if you use with other CLI tools while using PNPM as package manager #1605

Open
RIP21 opened this issue Nov 27, 2020 · 4 comments

Comments

@RIP21
Copy link

RIP21 commented Nov 27, 2020

Basically, I'm using graphql-cli in a PNPM Workspaces environment, and if fails with the error below for any other CLI Tool integration such as codegen, coverage and valdiate. Using codegen as standalone CLI works fine no matter their setup.

(node:3206114) UnhandledPromiseRejectionWarning: Error: ENOTDIR: not a directory, stat '/home/alos/Projects/LiveFlow/app-frontend/common/temp/node_modules/.pnpm/[email protected][email protected]/node_modules/graphql-cli/dist/bin.js/node_modules/@graphql-cli/*'
(node:3206114) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3206114) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

PNPM resolves modules in a different way than yarn and npm I assume you may expect flattening and having graphql-codegen to be available in node_modules/.bin and just spawning the process like ./bin/graphql-codegen <some-args> relative to cwd, but it's not there due to PNPM resolution strategy so it fails.
The obvious solution would be, to use the programmatic usage of CLIs tools mentioned above and not spawning the processes? Probably too much coding :)
I'm unsure :) From code I see that there are maybe some issues with the generator of sh file ./node_modules/./bin/graphql that handles symlinks improperly?

To Reproduce
Steps to reproduce the behavior:

  1. Use PNPM
  2. npx graphql-cli init
  3. Done
  4. Make sure you have everything in place for correct work of underlying CLI tools
  5. Run them.
  6. Get issue.

Expected behavior
Everything is working fine. Or at least meaningful error message is there :)

Screenshots
image

Versions (please complete the following information):

  • OS: latest Ubuntu
  • graphql-cli: 4.1.0
    "@graphql-cli/codegen": "1.17.15",
    "@graphql-cli/coverage": "2.1.0",
    "@graphql-cli/validate": "2.1.0",
    "@graphql-codegen/add": "2.0.2",
    "@graphql-codegen/near-operation-file-preset": "1.17.13",
    "@graphql-codegen/typescript": "1.18.1",
    "@graphql-codegen/typescript-operations": "1.17.12",
    "@graphql-codegen/typescript-urql": "2.0.3",

Generated graphql bin file

#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac


export NODE_PATH="/home/alos/Projects/LiveFlow/app-frontend/common/temp/node_modules/.pnpm/[email protected][email protected]/node_modules/graphql-cli/dist/bin.js/node_modules:/home/alos/Projects/LiveFlow/app-frontend/common/temp/node_modules/.pnpm/[email protected][email protected]/node_modules/graphql-cli/dist/node_modules:/home/alos/Projects/LiveFlow/app-frontend/common/temp/node_modules/.pnpm/[email protected][email protected]/node_modules/graphql-cli/node_modules:/home/alos/Projects/LiveFlow/app-frontend/common/temp/node_modules/.pnpm/[email protected][email protected]/node_modules:/home/alos/Projects/LiveFlow/app-frontend/common/temp/node_modules/.pnpm/node_modules:/home/alos/Projects/LiveFlow/app-frontend/common/temp/node_modules:/home/alos/Projects/LiveFlow/app-frontend/common/node_modules:/home/alos/Projects/LiveFlow/app-frontend/node_modules:/home/alos/Projects/LiveFlow/node_modules:/home/alos/Projects/node_modules:/home/alos/node_modules:/home/node_modules:/node_modules:/home/alos/Projects/LiveFlow/app-frontend/ui/app/node_modules:/home/alos/Projects/LiveFlow/app-frontend/ui/node_modules"
if [ -x "$basedir/node" ]; then
  exec "$basedir/node"  "$basedir/../../../../common/temp/node_modules/.pnpm/[email protected][email protected]/node_modules/graphql-cli/dist/bin.js" "$@"
else 
  exec node  "$basedir/../../../../common/temp/node_modules/.pnpm/[email protected][email protected]/node_modules/graphql-cli/dist/bin.js" "$@"
fi
@RIP21 RIP21 changed the title Seems to be broken if you use with other tools while in PNPM Seems to be broken if you use with other CLI tools while using PNPM as package manager Nov 27, 2020
@wtrocki
Copy link
Collaborator

wtrocki commented Nov 27, 2020

Never used CLI with this package manager.
There will be couple places where CLI (and depending packages) will fail. We do not test with anything else than npm or yarn

@RIP21
Copy link
Author

RIP21 commented Nov 27, 2020

You shall start testing with it as it is pretty popular :P
PNPM is major for all people that are using rush.js monorepo management tool. To name a few Microsoft, Revolut and many more.
PNPM is just amazing and IMO how npm should've been working from the day 1 :)

Anyway, mostly 99% of packages are working as is with PNPM, only CLIs are getting broken usually due to bin behavior (which is makes sense as it doesn't leak CLIs (bins) from transitive dependencies)

@tvvignesh
Copy link

Just tried installing graphql-cli using PNPM (since that's what I use) and I got the same error:

1

@RIP21
Copy link
Author

RIP21 commented Dec 24, 2020

Overall GraphQL CLI + Codegen + Inspector add-ons are seem to be very fragile. I cannot specify, but on multiple occasions using those tools through the CLI wrapper, I end up getting issues, so currently I'm using those tools CLIs directly as, fortunately they're working as expected.
And it's with regular npm. I'm not mentioning PNPM that is special.

I would rather keep init and few other commands unique to CLI in it, but rest would've removed for good to simplify maintenance.

As because I think you folks at Guild are having so much products to maintain I see their quality is worsened overtime and is not as perfect as it used to be and in integration they're not working quite often which is annoying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants