这是indexloc提供的服务,不要输入任何密码
Skip to content

[turborepo] Prune generates invalid pnpm-lock.yaml when injecting local workspace #5529

@gerbyzation

Description

@gerbyzation

What version of Turborepo are you using?

1.10.7

What package manager are you using / does the bug impact?

pnpm

What operating system are you using?

Mac

Describe the Bug

When using turbo prune on a workspace that has a local dependency injected
the generated lockfile has an invalid resolution field. When proceeding to install
the pruned repo this will cause the following error:

❯ pnpm i
Scope: all 3 workspace projects
Lockfile is up to date, resolution step is skipped
Packages: +8
++++++++
 ERR_INVALID_ARG_TYPE  The "path" argument must be of type string. Received undefined

pnpm [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:372:5)
    at validateString (node:internal/validators:120:11)
    at Object.join (node:path:1172:7)
    at directoryFetcher (/Users/gerbenneven/.fnm/node-versions/v16.15.1/installation/lib/node_modules/pnpm/dist/pnpm.cjs:102008:36)
    at fetcher (/Users/gerbenneven/.fnm/node-versions/v16.15.1/installation/lib/node_modules/pnpm/dist/pnpm.cjs:125428:22)
    at ctx.requestsQueue.add.priority.priority (/Users/gerbenneven/.fnm/node-versions/v16.15.1/installation/lib/node_modules/pnpm/dist/pnpm.cjs:125324:78)
    at run (/Users/gerbenneven/.fnm/node-versions/v16.15.1/installation/lib/node_modules/pnpm/dist/pnpm.cjs:124809:90)
    at PQueue._tryToStartAnother (/Users/gerbenneven/.fnm/node-versions/v16.15.1/installation/lib/node_modules/pnpm/dist/pnpm.cjs:124757:13)
    at /Users/gerbenneven/.fnm/node-versions/v16.15.1/installation/lib/node_modules/pnpm/dist/pnpm.cjs:124822:16
    at new Promise (<anonymous>)
Packages are copied from the content-addressable store to the virtual store.
  Content-addressable store is at: /Users/gerbenneven/Library/pnpm/store/v3
  Virtual store is at:             node_modules/.pnpm
Progress: resolved 1, reused 0, downloaded 0, added 0

The original lockfile has the following entry for lib-a:

  file:libraries/lib-b:
    resolution: {directory: libraries/lib-b, type: directory}
    name: lib-b
    version: 1.0.0
    dev: false

The pruned repo generates the following:

  file:libraries/lib-b:
    resolution:
      type: directory
    name: lib-b
    version: 1.0.0
    dev: false

Note the missing directory field on the resolution object.

Expected Behavior

turbo prune should generate a valid lockfile, specifically it shouldn't drop the resolution.directory field on the injected dependency.

To Reproduce

Repository with repro: https://github.com/gerbyzation/turbo-prune-pnpm-resolution-directory-missing-repro
Steps:

pnpm exec turbo prune --scope lib-a
cd out
pnpm install

Reproduction Repo

https://github.com/gerbyzation/turbo-prune-pnpm-resolution-directory-missing-repro

Metadata

Metadata

Labels

kind: bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions