Skip to content

Workspace detection breaks with ./ prefix in v7/v8 #4190

@blimmer

Description

@blimmer

Current Behavior

Yarn accepts a workspaces key with a ./ prefix in package.json.

{
  "name": "my-monorepo",
  "workspaces": ["./packages/*"]
}
> yarn workspaces list
➤ YN0000: .
➤ YN0000: packages/package-a
➤ YN0000: packages/package-b
➤ YN0000: Done in 0s 1ms

However, lerna does not identify these packages:

> yarn lerna list -all
lerna notice cli v8.2.2
lerna info versioning independent
lerna success found 0 packages

If you remove the ./ from the "workspaces" key:

{
  "name": "my-monorepo",
  "workspaces": ["packages/*"]
}

Then lerna shows the same values as yarn workspaces list.

> yarn lerna list -all
lerna notice cli v8.2.2
lerna info versioning independent
package-a v1.0.0 packages/package-a (PRIVATE)
package-b v1.0.0 packages/package-b (PRIVATE)
lerna success found 2 packages

Expected Behavior

Based on the documentation:

By default, lerna will try and reuse any workspaces configuration you may have from your package manager of choice.

I expected that workspaces valid in yarn would be valid in lerna.

This behavior changed and has been broken since lerna@7.

Steps to Reproduce

I created a repo to reproduce this problem here: https://github.com/blimmer/test-lerna-workspaces. See the README for details on using the repro case.

Failure Logs / Configuration

lerna.json

{
  "$schema": "node_modules/lerna/schemas/lerna-schema.json",
  "version": "independent",
  "npmClient": "yarn"
}

Environment

> yarn lerna info
lerna notice cli v8.2.2
lerna info versioning independent

 Environment info:

  System:
    OS: macOS 15.5
    CPU: (14) arm64 Apple M3 Max
  Binaries:
    Node: 22.16.0 - /private/var/folders/n4/12j2gpld1clc4jsz0rlxzr2r0000gn/T/xfs-51ccbe4a/node
    Yarn: 4.9.2 - /private/var/folders/n4/12j2gpld1clc4jsz0rlxzr2r0000gn/T/xfs-51ccbe4a/yarn
    npm: 10.9.2 - ~/.asdf/plugins/nodejs/shims/npm
  Utilities:
    Git: 2.49.0 - /opt/homebrew/bin/git
  npmPackages:
    lerna: ^8.2.2 => 8.2.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions