Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug?]: node-modules - Dependency with different major version in nested workspace not installed #3429

Closed
1 task
nicolo-ribaudo opened this issue Sep 12, 2021 · 7 comments · Fixed by #3438
Closed
1 task
Assignees
Labels
bug Something isn't working reproducible This issue can be successfully reproduced

Comments

@nicolo-ribaudo
Copy link
Contributor

nicolo-ribaudo commented Sep 12, 2021

Self-service

  • I'd be willing to implement a fix

Describe the bug

I have two nested packages. The outer one depends on ESLint 7, the inner one on ESLint 8. Only ESLint 7 is installed.

To reproduce

const { writeFile } = require("fs").promises;

await packageJson({
  private: true,
  dependencies: {
    eslint: "^7.0.0"
  }
},{ cwd: "workspace" })

await packageJson({
  private: true,
  dependencies: {
    eslint: "8.0.0-beta.2"
  }
},{ cwd: "workspace/nested" })

await writeFile(".yarnrc.yml", `nodeLinker: node-modules`);
await writeFile("workspace/nested/index.js", `module.exports = require("eslint/package.json").version`);

await packageJsonAndInstall({
  workspaces: ["workspace", "workspace/nested"]
});

const version = await node("workspace/nested/index.js");

expect(version).toBe("8.0.0-beta.2");

If this sherlock reproduction doesn't work, you can clone this branch: https://github.com/nicolo-ribaudo/babel/tree/yarn-bug-missing-dep. The last commit shows the package necessary to introduce the bug; you can run node eslint/babel-eslint-parser/test/eslint-8/index.js and it should print 8.0.0-beta.2.

Environment

System:
    OS: Linux 5.11 Ubuntu 21.04 (Hirsute Hippo)
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  Binaries:
    Node: 16.8.0 - /tmp/xfs-cc5b8bc4/node
    Yarn: 2.4.1-git.20210125.0f31e6910 - /tmp/xfs-cc5b8bc4/yarn
    npm: 7.21.1 - ~/.npm-global/bin/npm

Additional context

No response

@nicolo-ribaudo nicolo-ribaudo added the bug Something isn't working label Sep 12, 2021
@yarnbot

This comment has been minimized.

@yarnbot yarnbot added broken-repro The reproduction in this issue is broken reproducible This issue can be successfully reproduced and removed broken-repro The reproduction in this issue is broken labels Sep 12, 2021
@yarnbot

This comment has been minimized.

1 similar comment
@yarnbot
Copy link
Collaborator

yarnbot commented Sep 12, 2021

This issue reproduces on master:

Error: expect(received).toBe(expected) // Object.is equality

Expected: "8.0.0-beta.2"
Received: {}
    at module.exports (evalmachine.<anonymous>:27:17)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async /github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.2-91650a2501-627bee24a7.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:56:13
    at async executeInTempDirectory (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.2-91650a2501-627bee24a7.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:17:16)
    at async Object.executeRepro (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.2-91650a2501-627bee24a7.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:24:12)
    at async ExecCommand.execute (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-2.0.2-91650a2501-627bee24a7.zip/node_modules/@arcanis/sherlock/lib/commands/exec.js:25:38)
    at async ExecCommand.validateAndExecute (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-91cf93ba72.zip/node_modules/clipanion/lib/advanced/Command.js:161:26)
    at async Cli.run (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-91cf93ba72.zip/node_modules/clipanion/lib/advanced/Cli.js:74:24)
    at async Cli.runExit (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-91cf93ba72.zip/node_modules/clipanion/lib/advanced/Cli.js:83:28)

@merceyz
Copy link
Member

merceyz commented Sep 12, 2021

Both versions of ESLint is installed but both workspaces get access to the 7.x version due to the layout on disk

.
├── node_modules
│   └── eslint@8
└── workspace
    ├── node_modules
    │   └── eslint@7
    ├── nested
    │   └── package.json
    └── package.json

@arcanis
Copy link
Member

arcanis commented Sep 12, 2021

Seems to be a valid issue; the workspace/nested copy of eslint shouldn't be hoisted into its parent workspace (probably happens because of having a workspace inside a workspace).

cc @larixer

@larixer
Copy link
Member

larixer commented Sep 13, 2021

Seems to be a valid issue; the workspace/nested copy of eslint shouldn't be hoisted into its parent workspace (probably happens because of having a workspace inside a workspace).

The problem is actually different. The workspaces/nested copy is hoisted to the top-level, not to the parent workspace. The eslint copy in the parent workspace is correct. Looking....

@larixer
Copy link
Member

larixer commented Sep 14, 2021

@nicolo-ribaudo Just a heads up, I've took a stab to fix this issue at #3438, checked your example and it works for me now. Gotta add integration tests to the PR to prevent future regressions in the following days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working reproducible This issue can be successfully reproduced
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants