node-gh / gh

(DEPRECATED) GitHub CLI made with NodeJS. Use the official https://cli.github.com/ instead.
http://nodegh.io
Other
1.71k stars 217 forks source link

Missing dependency on sanctuary-def, required by fluture-sanctuary-types #758

Closed cspotcode closed 4 years ago

cspotcode commented 4 years ago

Version number In which version does the bug appear?

2.8.5

Describe the bug

gh depends on fluture-sanctuary-types, which declares a peerDependency on sanctuary-def. However, gh does not declare a dependency on sanctuary-def, so the required dependency is missing. This conveniently works only if the dependency is hoisted from sanctuary, but that doesn't always happen. It fails when running under yarn 2.

https://github.com/node-gh/gh/blob/master/package.json#L159-L173 https://github.com/fluture-js/fluture-sanctuary-types/blob/master/package.json#L44

https://github.com/sanctuary-js/sanctuary/blob/master/package.json#L17

To fix

Add a dependency on sanctuary-def:

npm install --save sanctuary-def

To Reproduce

Use yarn dlx to run gh. yarn dlx is akin to npx.

# cd to an empty project directory
npm install --global yarn
yarn set version berry
yarn dlx gh

Expected behavior

gh is compatible with tools like yarn dlx and `npm

Log

➤ YN0000: ┌ Resolution step
➤ YN0002: │ gh@npm:2.8.5 doesn't provide sanctuary-def@>=0.20.0 <0.21.0 requested by fluture-sanctuary-types@npm:4.1.1
➤ YN0060: │ gh@npm:2.8.5 provides marked@npm:0.7.0 with version 0.7.0 which doesn't satisfy ^0.4.0 || ^0.5.0 || ^0.6.0 requested by marked-terminal@npm:3.2.0
➤ YN0000: └ Completed in 4.54s
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 0.24s
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed in 0.68s
➤ YN0000: Done with warnings in 5.47s

/tmp/tmp-19734ZwM9KNy1D4EX/dlx-19734/.pnp.js:16726
    throw firstError;
    ^

Error: A package is trying to access a peer dependency that should be provided by its direct ancestor but isn't

Required package: sanctuary-def (via "sanctuary-def")
Required by: fluture-sanctuary-types@virtual:2c3ded57fc2c5b6e3394902c63ddcc928d7caaa8706d2cc583bc3193a87eba2c99e854d9b4a868d7118f0dc558a567a4bbd3053134b310887147c35cdd07f4fb#npm:4.1.1 (via /tmp/tmp-19734ZwM9KNy1D4EX/dlx-19734/.yarn/$$virtual/fluture-sanctuary-types-virtual-7f00e85a18/4/home/abradley-pengwin/.yarn/berry/cache/fluture-sanctuary-types-npm-4.1.1-79941f05f3-1.zip/node_modules/fluture-sanctuary-types/)

Require stack:
- /tmp/tmp-19734ZwM9KNy1D4EX/dlx-19734/.yarn/$$virtual/fluture-sanctuary-types-virtual-7f00e85a18/4/home/abradley-pengwin/.yarn/berry/cache/fluture-sanctuary-types-npm-4.1.1-79941f05f3-1.zip/node_modules/fluture-sanctuary-types/index.js
- /home/abradley-pengwin/.yarn/berry/cache/gh-npm-2.8.5-2c3ded57fc-1.zip/node_modules/gh/lib/cmd.js
- /home/abradley-pengwin/.yarn/berry/cache/gh-npm-2.8.5-2c3ded57fc-1.zip/node_modules/gh/bin/gh.js
    at Object.makeError (/tmp/tmp-19734ZwM9KNy1D4EX/dlx-19734/.pnp.js:8471:24)
    at resolveToUnqualified (/tmp/tmp-19734ZwM9KNy1D4EX/dlx-19734/.pnp.js:17318:35)
    at resolveRequest (/tmp/tmp-19734ZwM9KNy1D4EX/dlx-19734/.pnp.js:17411:27)
    at Object.resolveRequest (/tmp/tmp-19734ZwM9KNy1D4EX/dlx-19734/.pnp.js:17479:26)
    at Function.module_1.Module._resolveFilename (/tmp/tmp-19734ZwM9KNy1D4EX/dlx-19734/.pnp.js:16709:34)
    at Function.module_1.Module._load (/tmp/tmp-19734ZwM9KNy1D4EX/dlx-19734/.pnp.js:16594:40)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at /tmp/tmp-19734ZwM9KNy1D4EX/dlx-19734/.yarn/$$virtual/fluture-sanctuary-types-virtual-7f00e85a18/4/home/abradley-pengwin/.yarn/berry/cache/fluture-sanctuary-types-npm-4.1.1-79941f05f3-1.zip/node_modules/fluture-sanctuary-types/index.js:2:83
    at Object.<anonymous> (/tmp/tmp-19734ZwM9KNy1D4EX/dlx-19734/.yarn/$$virtual/fluture-sanctuary-types-virtual-7f00e85a18/4/home/abradley-pengwin/.yarn/berry/cache/fluture-sanctuary-types-npm-4.1.1-79941f05f3-1.zip/node_modules/fluture-sanctuary-types/index.js:5:2) {
  code: 'MODULE_NOT_FOUND',
  pnpCode: 'MISSING_PEER_DEPENDENCY',
  data: {
    request: 'sanctuary-def',
    issuer: '/tmp/tmp-19734ZwM9KNy1D4EX/dlx-19734/.yarn/$$virtual/fluture-sanctuary-types-virtual-7f00e85a18/4/home/abradley-pengwin/.yarn/berry/cache/fluture-sanctuary-types-npm-4.1.1-79941f05f3-1.zip/node_modules/fluture-sanctuary-types/',
    issuerLocator: {
      name: 'fluture-sanctuary-types',
      reference: 'virtual:2c3ded57fc2c5b6e3394902c63ddcc928d7caaa8706d2cc583bc3193a87eba2c99e854d9b4a868d7118f0dc558a567a4bbd3053134b310887147c35cdd07f4fb#npm:4.1.1'
    },
    dependencyName: 'sanctuary-def'
  },
  requireStack: [
    '/tmp/tmp-19734ZwM9KNy1D4EX/dlx-19734/.yarn/$$virtual/fluture-sanctuary-types-virtual-7f00e85a18/4/home/abradley-pengwin/.yarn/berry/cache/fluture-sanctuary-types-npm-4.1.1-79941f05f3-1.zip/node_modules/fluture-sanctuary-types/index.js',
    '/home/abradley-pengwin/.yarn/berry/cache/gh-npm-2.8.5-2c3ded57fc-1.zip/node_modules/gh/lib/cmd.js',
    '/home/abradley-pengwin/.yarn/berry/cache/gh-npm-2.8.5-2c3ded57fc-1.zip/node_modules/gh/bin/gh.js'
  ]
}

Additional context

protoEvangelion commented 4 years ago

Thanks for the super thorough and clear bug report..that is rare!

I wasn't able to repro with yarn berry:

image

Nonetheless, I'll deploy with the dependency & see if that resolves it :)

protoEvangelion commented 4 years ago

:tada: This PR is included in version 2.8.6 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

protoEvangelion commented 4 years ago

Please let me know if this is still an issue. Thanks again!

protoEvangelion commented 4 years ago

@all-contributors please add @cspotcode for bug

allcontributors[bot] commented 4 years ago

@protoEvangelion

I've put up a pull request to add @cspotcode! :tada: