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

eventually move to Yarn 2+ (currently 4) #451

Open
warner opened this issue Jan 24, 2020 · 10 comments · May be fixed by #8461
Open

eventually move to Yarn 2+ (currently 4) #451

warner opened this issue Jan 24, 2020 · 10 comments · May be fixed by #8461
Assignees
Labels
devex developer experience hygiene Tidying up around the house

Comments

@warner
Copy link
Member

warner commented Jan 24, 2020

@katelynsills and @btulloh noticed that the Yarn docs encourage folks to install Yarn 2, but this tree only works with Yarn 1. A quick survey showed that many (all?) of us have Yarn 1 installed locally, so we haven't noticed the problem before.

Ideally our tree should work with both versions. Fallback position is to work with Yarn 2 and make sure the docs point people at installing it rather than yarn 1 (with a stretch goal of somehow detecting when you're using yarn 1 and printing a useful error message).

@katelynsills
Copy link
Contributor

I think we can specify the version of yarn to use by entering (yarn policies set-version $VERSION) and committing the results. I have yarn 2 installed and used by default, but after making this change in a package (to yarn 1.21.1), it runs yarn 1.

Also here's a very informative blog post on what's new in Yarn 2: https://dev.to/arcanis/introducing-yarn-2-4eh1

@warner
Copy link
Member Author

warner commented Jan 29, 2020

Hm, I did that, and the two files it added were .yarnrc (makes sense) and a 5MB .yarn/releases/yarn-1.21.1.js (which seems overkill). I'm guessing it's copying the entire Yarn executable into our source tree. Any idea how we might make this better?

Cc @jfparadis @michaelfig in case you've got some ideas

@warner
Copy link
Member Author

warner commented Jan 29, 2020

Hrm, reading https://legacy.yarnpkg.com/en/docs/cli/policies it seems like this is the intended behavior (and they don't find it to be a big deal). If that seems reasonable to everyone else, I'll make a PR for it.

@katelynsills
Copy link
Contributor

Sounds good to me

warner added a commit that referenced this issue Jan 29, 2020
Following the recommendations at
https://legacy.yarnpkg.com/en/docs/cli/policies , I ran `yarn policies
set-version 1`, which added a copy of the now-current 1.21.1 to `.yarn/` and
added a `.yarnrc` to use it. I believe no matter what version of Yarn you
have installed locally, when you run `yarn COMMAND`, your yarn will delegate
everything to this yarn-1.21.1 .

Now that yarn-2 has been released, we'll need this pinning to keep things
working even when developers have yarn-2 installed on their machines.

refs #451
@warner warner mentioned this issue Jan 29, 2020
warner added a commit that referenced this issue Jan 31, 2020
Following the recommendations at
https://legacy.yarnpkg.com/en/docs/cli/policies , I ran `yarn policies
set-version 1`, which added a copy of the now-current 1.21.1 to `.yarn/` and
added a `.yarnrc` to use it. I believe no matter what version of Yarn you
have installed locally, when you run `yarn COMMAND`, your yarn will delegate
everything to this yarn-1.21.1 .

Now that yarn-2 has been released, we'll need this pinning to keep things
working even when developers have yarn-2 installed on their machines.

refs #451
@warner
Copy link
Member Author

warner commented Jan 31, 2020

Ok, we're pinned to yarn-1.21.1 now. I'll rename the ticket to reflect a low-priority goal to move to Yarn 2 once it's stable and ready.

@warner warner changed the title work with both yarn 1 and yarn 2 eventually move to Yarn 2 Jan 31, 2020
@katelynsills katelynsills added the hygiene Tidying up around the house label Feb 8, 2021
@warner
Copy link
Member Author

warner commented Mar 17, 2023

https://yarnpkg.com/getting-started/migration/ has notes on how one might make this transition.

@turadg turadg added the devex developer experience label Oct 18, 2023
@turadg turadg linked a pull request Oct 18, 2023 that will close this issue
@turadg turadg self-assigned this Oct 18, 2023
@turadg turadg changed the title eventually move to Yarn 2 eventually move to Yarn 2+ (currently 4) Nov 3, 2023
@dckc
Copy link
Member

dckc commented Dec 22, 2023

@turadg , I bemoaned the fact that yarn build rebuilds everything in our tree, even things where the inputs haven't changed. You referred to this issue as a solution. I'm struggling to confirm that yarn 2 is supposed to have this "build only stuff whose inputs have changed" feature. I'm running into measurements that show yarn 2 is slower, in fact:

Speed winner: Yarn 1 by a long shot.
-- Yarn 1 vs Yarn 2 vs NPM... 2020

Help me find docs on the build performance optimizations in yarn 2+, please?

@turadg
Copy link
Member

turadg commented Dec 22, 2023

Help me find docs on the build performance optimizations in yarn 2+, please?

Cached is the most common case. The doc you linked to shows 14s vs 29s for 2.0-rc.27 vs v1 (whatever version was ~4 yrs ago).

For more recent data: https://yarnpkg.com/features/performances

yarn build rebuilds everything in our tree, even things where the inputs haven't changed. You referred to this issue as a solution.

Correct. Are you also asking for confirmation of that? Check out #8461 (in a new directory avoid borking your current node_modules) and run yarn install a couple times.

Then to see what it's like changing between branches, bump a dep. E.g. "typescript" to 5.3.3 in the root package.json. yarn install again to warm the cache. Then reset hard to simulate switching from a feature branch back to master.

With v3 it completes in ~1s:

➤ YN0000: ┌ Resolution step
➤ YN0002: │ @agoric/wallet@workspace:packages/wallet doesn't provide eslint (p148d7), requested by babel-eslint
➤ YN0002: │ @agoric/wallet@workspace:packages/wallet doesn't provide eslint (pcc945), requested by eslint-plugin-eslint-comments
➤ YN0002: │ @endo/eslint-plugin@npm:2.0.0 doesn't provide eslint (pa1d77), requested by @typescript-eslint/utils
➤ YN0002: │ @endo/pass-style@npm:0.1.7 doesn't provide ava (pa91ef), requested by @fast-check/ava
➤ YN0002: │ @endo/pass-style@npm:1.0.1 doesn't provide ava (pf2e1c), requested by @fast-check/ava
➤ YN0002: │ @lerna/version@npm:5.6.2 doesn't provide nx (p20b2d), requested by @nrwl/devkit
➤ YN0060: │ agoric@workspace:packages/agoric-cli provides @yarnpkg/core (pd0bee) with version 3.5.4, which doesn't satisfy what @yarnpkg/cli and some of its descendants request
➤ YN0002: │ type-coverage@npm:2.26.3 doesn't provide typescript (pf744c), requested by type-coverage-core
➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
➤ YN0000: └ Completed in 0s 257ms
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0008: │ @agoric/sdk@workspace:. must be rebuilt because its dependency tree changed
➤ YN0000: └ Completed in 0s 778ms
➤ YN0000: Done with warnings in 1s 368ms

Whereas with v1 (master) it takes ~7s:

❯ time yarn install
yarn install v1.22.19
[1/5] 🔍  Validating package.json...
[2/5] 🔍  Resolving packages...
[3/5] 🚚  Fetching packages...
[4/5] 🔗  Linking dependencies...
warning " > @agoric/eslint-config@0.4.0" has incorrect peer dependency "eslint-plugin-jsdoc@^40.1.0".
[5/5] 🔨  Building fresh packages...
$ patch-package
patch-package 6.5.1
Applying patches...
@agoric/wallet-ui@0.1.3-solo.0 ✔
@lerna/conventional-commits@5.6.2 ✔
@lerna/version@5.6.2 ✔
acorn@8.10.0 ✔
ava@5.3.0 ✔
bufferfromfile@0.4.377 ✔
depd@2.0.0 ✔
encoding@0.1.13 ✔
express@4.18.1 ✔
external-editor@3.1.0 ✔
node-fetch@2.6.12 ✔
protobufjs@6.11.3 ✔
readable-stream@3.6.2 ✔
rxjs@7.5.5 ✔
✨  Done in 6.84s.
yarn install  6.40s user 2.47s system 124% cpu 7.107 total

There are other advantages upgrading to v2+:

  • workspace protocol (so we don't have to maintain version numbers in all deps)
  • patch protocol (so we don't need patch-package)
  • constraints (e.g. to enforce layering)
  • path to adopt pnpm-style linker (without changing the UI)

@dckc
Copy link
Member

dckc commented Dec 22, 2023

yarn build rebuilds everything in our tree, even things where the inputs haven't changed. You referred to this issue as a solution.

Correct. Are you also asking for confirmation of that?

I'm trying to understand how yarn 2 is supposed to help with build performance. I thought you might have a quick pointer to docs on how yarn 2 uses something like make's dependency tracking to avoid work that yarn 1 does.

Check out #8461 (in a new directory avoid borking your current node_modules) and run yarn install a couple times.

OK, so this is about yarn install? I suppose building xsnap is in that pile...

But I'm also concerned about yarn build. Should I expect yarn 2 to help there too?

Then to see what it's like changing between branches,

yeah; what's necessary in that case is a mystery to me...

With v3 it completes in ~1s:

A step that takes 1s is easier than thinking.

There are other advantages upgrading to v2+:

thanks for all the info.

@turadg
Copy link
Member

turadg commented Dec 23, 2023

concerned about yarn build. Should I expect yarn 2 to help there too?

Not much. It does add the ability to run a task only in workspaces in topological order and/or only that have changed since some ref. However that won't be new to the repo as Lerna does that now. What it could mean is getting off Lerna if we can get back with yarn+changesets.

mergify bot added a commit that referenced this issue Apr 26, 2024
refs: #451
refs: #9209 

## Description

We need agoric-sdk's integration tests to work with Endo running Yarn 4.
#9285 tested against
endojs/endo#2222. This PR is to land the
necessary changes in master so the Endo PR can land without breaking SDK
CI.

This helps with #9209 and is a subset of
#9286 , all that we need for
Endo right now.

### Security Considerations

none

### Scaling Considerations

none, build time

### Documentation Considerations

Nothing for SDK

### Testing Considerations

CI

### Upgrade Considerations

n/a
kriskowal added a commit to endojs/endo that referenced this issue Apr 26, 2024
closes: #2245 
refs: Agoric/agoric-sdk#451
refs: Agoric/ui-kit#105

## Description

Move from Yarn 1 to Yarn 4. Some advantages,

- actively maintained
- [workspace protocol](https://yarnpkg.com/protocol/workspace) (so we
don't have to maintain version numbers in all deps)
- [patch protocol](https://yarnpkg.com/protocol/patch) (so we don't need
patch-package)
- [constraints](https://yarnpkg.com/features/constraints) (e.g. to
enforce layering)
- path to adopt pnpm-style linker (without changing the UI) (see
#1722 )

However this defers workspace protocol until the publishing workflow can
support it.

### Security Considerations

This does a bulk update of `yarn.lock`. It was automated by Yarn 4.

### Scaling Considerations

n/a

### Documentation Considerations

I reviewed `yarn` commands in *.md and I think they're all accurate.

### Testing Considerations

This could interact with the publishing pipeline. @kriskowal may want to
push a draft before we merge. If problems are found, depending on the
severity, we could follow up in a separate PR to land this sooner reduce
merge conflicts.

This was failing on the Windows tests, something about corepack not
taking effect. I don't know whether Windows is officially supported by
Endo. We've since disabled them.
#2243 is the issue restore.


### Compatibility Considerations

Some CLI commands are slightly different. We are adopting it across the
org so we have to adjust sometime.

### Upgrade Considerations

n/a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devex developer experience hygiene Tidying up around the house
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants