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

[rush] rush add "package" when using yarn doesn't actually add the package #2928

Open
MichaelBelousov opened this issue Sep 24, 2021 · 3 comments

Comments

@MichaelBelousov
Copy link

MichaelBelousov commented Sep 24, 2021

Summary

when using rush over yarn, adding packages doesn't work unless you purge and update after. (On my linux machine, purging doesn't seem to be necessary but it is on my windows machine).

With rush over pnpm, when you run cd packages/myproject && rush add -p some-package, the package is added to your package.json the relevant lockfile, installed, and linked from the merged package's node_modules to your project's node_modules.

With yarn, it is only added to the package.json. A rush update occurs which reports the following warning:

The shrinkwrap file (yarn.lock) contains the following issues:
  Missing dependency "lodash.pick" (~4.4.0) required by "proj1"

It is not installed or linked, and the lockfile isn't updated. After some testing, running rush update --full successfully installs and links the package after, but on non-toy projects you don't always want to update all dependencies just to install a new one.

It may be important to note that I can't use pnpm in my monorepo because I produce an electron app, and electron's utilities often don't follow links and assume a naive node_modules layout. Until that is fixed, you have to use npm or yarn.

Repro steps

Here is an mvr repo I prepared, check it out and run the repro.sh script after reading it, and you can run the reset.sh script if necessary to restore the repo state. I have reproduced its contents and important output below so you can see it

Output (excluding rush's output, just the repo state that repro.sh prints to stdout)

LINKED MODULES
node_modules
node_modules/lazy-from

ALL MODULES
../../common/temp/node_modules
../../common/temp/node_modules/@rush-temp
../../common/temp/node_modules/.yarn-integrity
../../common/temp/node_modules/lazy-from

PACKAGE.JSON
{
  "name": "proj1",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "lazy-from": "~1.1.1",
    "lodash.pick": "~4.4.0"
  }
}

YARN.LOCK
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


"@rush-temp/proj1@file:./projects/proj1.tgz":
  version "0.0.0"
  resolved "file:./projects/proj1.tgz#d12365c6ba1a4ab080edcc54c46602e10fff4f75"
  dependencies:
    lazy-from "~1.1.1"

lazy-from@~1.1.1:
  version "1.1.1"
  resolved "https://registry.yarnpkg.com/lazy-from/-/lazy-from-1.1.1.tgz#eac9e06dbdf8a31332ec993ff211dfcec509fd42"
  integrity sha512-IC8L8XNTRncqodcjXNMML4u4T6kR/ATCotbss5ymYzDtb8RRYxTaxHM0ZDzyYavAkHhY8vLNxL4RKcaXPcTFRQ==

Fixup command behavior:

after testing the mvr on windows on the latest rush+yarn versions as I did on linux, they appeared to have the exact same behavior.

command ran after rush add effects
rush update lockfile is updated, package installed to common/temp/node_modules but not linked in proj1
rush update && rush link lockfile is updated, package installed to common/temp/node_modules but not linked in proj1
rush update --full successfully installs and links package

On an older version of rush on windows, I would have to run rush purge && rm -f common/config/rush/yarn.lock && rush update

Standard questions

Question Answer
@microsoft/rush globally installed version? 5.54.0
rushVersion from rush.json? 5.54.0
yarnVersion from rush.json? 1.22.11
useWorkspaces from rush.json? No
Operating system? Linux/Windows
Would you consider contributing a PR? Yes
Node.js version (node -v)? 12.18.4
@knicola
Copy link

knicola commented Oct 3, 2021

same here. can confirm both the issue and the workaround (which is quite inconvenient).

  • rushVersion: 5.54.0
  • yarnVersion: 1.22.15
  • node.js version: 16.8.0

had to switch to yarn because nuxt.js is currently incompatible with pnpm.

@MichaelBelousov
Copy link
Author

as a note, 99% of the electron community tools are also incompatible with pnpm which is why I'm using rush + yarn

@PrimarchAlpharius
Copy link

Probably related to #1748 , would be great if this got fixed, makes using yarn very slow, having to do a full purge and update just to update a single package.

@iclanton iclanton moved this to Needs Investigation in Bug Triage Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs Investigation
Development

No branches or pull requests

3 participants