Skip to content

Yarn more than one workspace #3986

@maoueh

Description

@maoueh

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
Doing some yarn command a second time using workspaces feature may fail with There are more than one workspace with name "XXX" error if a package is conflicting and not hoisted at top-level and when the workspaces option is a glob englobing pattern.

If the current behavior is a bug, please provide the steps to reproduce.

See https://github.com/maoueh/yarn-workspace-already-exist-bug that has all the instructions, copied here for easiest repro:

  1. Clone repository

    $ git clone https://github.com/maoueh/yarn-workspace-already-exist-bug.git /tmp/yarn-workspace-already-exist-bug
    
  2. Yarn install once

    $ cd /tmp/yarn-workspace-already-exist-bug
    $ yarn install
    
  3. Yarn install a second time to see the error:

    $ yarn install
    yarn install v0.28.1
    error There are more than one workspace with name "ramda"
    info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
    

What is the expected behavior?

There should not be a problem doing a second yarn install.

Extra Info

The problem I think is simply that Yarn is looking in node_modules folders to determined workspaces. For example, with the pattern packages/**/*, and with the tree:

├── node_modules
├── package.json
├── packages
│   ├── a
│   │   └── package.json
│   ├── b
│   │   ├── node_modules
│            └── ramda
│   │   └── package.json
│   └── c
│       ├── node_modules
│            └── ramda
│       └── package.json
└── yarn.lock

Yarn is finding packages/b/nodes_modules/ramda and packages/c/nodes_modules/ramda as being a valid workspace while it's a simple dependency.

Please mention your node.js, yarn and operating system version.
Yarn 0.28.1
Node 7.9
Mac OS X

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions