crystal icon indicating copy to clipboard operation
crystal copied to clipboard

can't install with yarn berry

Open kilianc opened this issue 5 years ago • 4 comments
trafficstars

Error: graphile-utils tried to access graphile-build-pg (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.

this seems to be related to a peer dependency not declared in the package.json

kilianc avatar Mar 16 '20 02:03 kilianc

looks like graphile-build-pg is missing and it's required by https://github.com/graphile/graphile-engine/blob/master/packages/graphile-utils/package.json

kilianc avatar Mar 16 '20 02:03 kilianc

FWIW I managed to fix this by making the following addition to .yarnrc.yml

yarnPath: .yarn/releases/yarn-2.1.1.cjs
packageExtensions:
  postgraphile@^4.9.0:
    peer-dependencies:
      graphql: ">=0.9 <0.14 || ^14.0.2"
    dependencies:
      graphile-build: "^4.5.0"
      graphile-build-pg: "^4.5.0"
  graphile-build@^4.5.0:
    dependencies:
      graphql: ">=0.9 <0.14 || ^14.0.2"
  graphile-build-pg@^4.5.0:
    dependencies:
      graphql: ">=0.9 <0.14 || ^14.0.2"

mrjackdavis avatar Sep 20 '20 05:09 mrjackdavis

A small follow up to my last message...

For each graphile plugin, you need to include it as a dependency in .yarnrc.yml

e.g. to run yarn start with the following package.json

{
  "name": "foo",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "graphql": ">=0.9 <0.14 || ^14.0.2",
    "postgraphile": "^4.9.0",
    "postgraphile-plugin-connection-filter": "^2.0.0"
  },
  "scripts": {
    "start": "postgraphile -s app -c \"postgres://${API_DB_USER}:${API_DB_PASSWORD}@localhost:${API_DB_LOCAL_PORT}/${API_DB_API_DBNAME}\" --append-plugins postgraphile-plugin-connection-filter"
  }
}

You would need a .yarnrc.yml file similar to the following

yarnPath: .yarn/releases/yarn-2.1.1.cjs
packageExtensions:
  postgraphile@^4.9.0:
    peer-dependencies:
      graphql: ">=0.9 <0.14 || ^14.0.2"
    dependencies:
      graphile-build: "^4.5.0"
      graphile-build-pg: "^4.5.0"
      postgraphile-plugin-connection-filter: "*"
  graphile-build@^4.5.0:
    dependencies:
      graphql: ">=0.9 <0.14 || ^14.0.2"
  graphile-build-pg@^4.5.0:
    dependencies:
      graphql: ">=0.9 <0.14 || ^14.0.2"

Note postgraphile-plugin-connection-filter exists under postgraphile dependencies

I'd hope there's a better solution, but I'm not familiar enough with berry to know what that could be.

mrjackdavis avatar Sep 28 '20 04:09 mrjackdavis

modify to * for all package I think it will be better:

// .yarnrc.yml
yarnPath: .yarn/releases/yarn-2.3.3.cjs
packageExtensions:
  postgraphile@*:
    peer-dependencies:
      graphql: "*"
    dependencies:
      graphile-build: "*"
      graphile-build-pg: "*"
      postgraphile-plugin-connection-filter: "*"
  graphile-build@*:
    dependencies:
      graphql: "*"
  graphile-build-pg@*:
    dependencies:
      graphql: "*"

hiepxanh avatar Nov 02 '20 17:11 hiepxanh

V5 installs under yarn berry just fine; and we now have a lint script to detect issues with peer dependencies and the like. We're also doing hideous things with re-exporting paths to appease the various package managers who cannot guarantee a module will be installed as a singleton :roll_eyes:

benjie avatar Sep 29 '23 17:09 benjie