nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.38k stars 2.33k forks source link

Incorrect lockfile generation with yarn 4 #20928

Closed pvorona closed 2 months ago

pvorona commented 9 months ago

Current Behavior

Invalid lock file is generated when optional peer dependency is available at the root level when using yarn 4.

Expected Behavior

Valid yarn.lock is generated.

GitHub Repo

https://github.com/pvorona/nx-invalid-lockfile

Steps to Reproduce

  1. Create nx workspace with yarn 4 package manager and add the following dependencies to the root package.json:
    yarn add langchain @pinecone-database/pinecone
  2. Create project (app) inside the workspace with only one dependency langchain
  3. Build project app with "generatePackageJson": true
  4. Navigate to compiled project
    cd dist/app
  5. Try running yarn command in the compiled project:
    
    yarn add express

Internal Error: Invalid descriptor () at nh (/Users/pavelvorona/.cache/node/corepack/yarn/4.0.2/yarn.js:140:109585) at St.setupResolutions (/Users/pavelvorona/.cache/node/corepack/yarn/4.0.2/yarn.js:210:1274) at async St.find (/Users/pavelvorona/.cache/node/corepack/yarn/4.0.2/yarn.js:207:9452) at async bh.execute (/Users/pavelvorona/.cache/node/corepack/yarn/4.0.2/yarn.js:392:11773) at async bh.validateAndExecute (/Users/pavelvorona/.cache/node/corepack/yarn/4.0.2/yarn.js:94:787) at async as.run (/Users/pavelvorona/.cache/node/corepack/yarn/4.0.2/yarn.js:98:3250) at async oPt (/Users/pavelvorona/.cache/node/corepack/yarn/4.0.2/yarn.js:734:11269) at async sk (/Users/pavelvorona/.cache/node/corepack/yarn/4.0.2/yarn.js:734:11625)


### Nx Report

```shell
Node   : 18.17.1
   OS     : darwin-arm64
   yarn   : 4.0.2

   nx (global)        : 17.2.6
   nx                 : 17.2.7
   @nx/js             : 17.2.7
   @nx/jest           : 17.2.7
   @nx/linter         : 17.2.7
   @nx/eslint         : 17.2.7
   @nx/workspace      : 17.2.7
   @nx/devkit         : 17.2.7
   @nx/eslint-plugin  : 17.2.7
   @nx/node           : 17.2.7
   @nrwl/tao          : 17.2.7
   @nx/webpack        : 17.2.7
   typescript         : 5.2.2

Failure Logs

No response

Package Manager Version

4.0.2

Operating System

Additional Information

No response

z0w0 commented 9 months ago

I'm also hitting this. Downgrading to 3.7.0 also isn't working

timofei-iatsenko commented 7 months ago

Have the same issue:

The generated lock file contains empty descriptor "":

"":
  version: 1.22.8
  resolution: "resolve@patch:resolve@npm%3A1.22.8#~builtin<compat/resolve>::version=1.22.8&hash=c3c19d"
  dependencies:
    is-core-module: "npm:^2.13.0"
    path-parse: "npm:^1.0.7"
    supports-preserve-symlinks-flag: "npm:^1.0.0"
  bin:
    resolve: bin/resolve
  checksum: 5479b7d431cacd5185f8db64bfcb7286ae5e31eb299f4c4f404ad8aa6098b77599563ac4257cb2c37a42f59dfc06a1bec2bcf283bb448f319e37f0feb9a09847
  languageName: node
  linkType: hard

Where entry in original lockfile is:

"resolve@patch:resolve@npm%3A1.22.8#~builtin<compat/resolve>, resolve@patch:resolve@npm%3A^1.1.7#~builtin<compat/resolve>, resolve@patch:resolve@npm%3A^1.12.0#~builtin<compat/resolve>, resolve@patch:resolve@npm%3A^1.14.2#~builtin<compat/resolve>, resolve@patch:resolve@npm%3A^1.20.0#~builtin<compat/resolve>":
  version: 1.22.8
  resolution: "resolve@patch:resolve@npm%3A1.22.8#~builtin<compat/resolve>::version=1.22.8&hash=c3c19d"
  dependencies:
    is-core-module: "npm:^2.13.0"
    path-parse: "npm:^1.0.7"
    supports-preserve-symlinks-flag: "npm:^1.0.0"
  bin:
    resolve: bin/resolve
  checksum: 5479b7d431cacd5185f8db64bfcb7286ae5e31eb299f4c4f404ad8aa6098b77599563ac4257cb2c37a42f59dfc06a1bec2bcf283bb448f319e37f0feb9a09847
  languageName: node
  linkType: hard

The same with yarn@3

timofei-iatsenko commented 7 months ago

Also a duplicate https://github.com/nrwl/nx/issues/19881

0b3r commented 3 months ago

Is there any update on this or workarounds?

MaxKless commented 2 months ago

I'll close this as it looks like an exact duplicate of https://github.com/nrwl/nx/issues/19881 Let's continue the discussion there.

github-actions[bot] commented 1 month ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.