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

Fixed concurrent unpacks into the same folder #3090

Merged
merged 1 commit into from Apr 10, 2017

Conversation

bestander
Copy link
Member

@bestander bestander commented Apr 10, 2017

Summary

This is a mitigation for issue #2629.
In some cases two different packages could end up unpacking into the same cache folder.
Example #2629 (comment), package typescript is downloaded twice because yarn.lock has inconsistent entries.
This change prevents more than one package to be unpacked into the same cache folder.

This is not a final fix for #2629, there is a more specific bug in resolver that causes this internal inconsistency but I think fetcher should check that every package will be extracted in a unique folder anyway.

Test plan

  • I'll add a unit test in the next PR when I'll be fixing the reason for the same package having 2 downloads
  • Manual test plan
  1. Check out yarn install fails with ENOENT: no such file or directory occasionallyΒ #2629 (comment)
  2. yarn install
yarn install v0.24.0-0
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
warning Pattern ["@angular/core@^2.0.0"] is trying to unpack in the same destination "/Users/bestander/Library/Caches/Yarn/v1/npm-@angular/core-4.0.0-rc.1-7f87b7696b407476e45d6d3c1880a50d5afbb6e3" as pattern ["@angular/core@4.0.0-rc.1","@angular/core@>=2.3.1 <5.0.0 || >=4.0.0-beta <5.0.0"]. This could result in a non deterministic behavior, skipping.
warning Pattern ["typescript@>=2.0.0 <2.2.0"] is trying to unpack in the same destination "/Users/bestander/Library/Caches/Yarn/v1/npm-typescript-2.2.1-4862b662b988a4c8ff691cc7969622d24db76ae9" as pattern ["typescript@2.2.1","typescript@>=2.1.4"]. This could result in a non deterministic behavior, skipping.
[3/4] πŸ”—  Linking dependencies...
warning "@angular/flex-layout@2.0.0-rc.1" has incorrect peer dependency "@angular/common@^2.2.3".
warning "@angular/flex-layout@2.0.0-rc.1" has incorrect peer dependency "@angular/core@^2.2.3".
warning "@angular/material@2.0.0-beta.2" has incorrect peer dependency "@angular/core@^2.3.0".
warning "@angular/material@2.0.0-beta.2" has incorrect peer dependency "@angular/common@^2.3.0".
warning "@angular/material@2.0.0-beta.2" has incorrect peer dependency "@angular/http@^2.3.0".
warning "@ngrx/effects@2.0.0" has incorrect peer dependency "@angular/core@^2.0.0".
warning "@ngrx/store@2.2.1" has incorrect peer dependency "@angular/core@^2.0.0".
warning "angular2-notifications@0.4.53" has incorrect peer dependency "@angular/core@^2.1.2".
warning "angular2-notifications@0.4.53" has incorrect peer dependency "@angular/common@^2.1.2".
warning "angular2-notifications@0.4.53" has incorrect peer dependency "@angular/platform-browser@^2.1.1".
warning "ng2-translate@5.0.0" has incorrect peer dependency "@angular/core@^2.0.0".
warning "ng2-translate@5.0.0" has incorrect peer dependency "@angular/http@^2.0.0".
warning "redux-batched-actions@0.1.5" has unmet peer dependency "redux@>=1.0.0".
[4/4] πŸ“ƒ  Building fresh packages...
✨  Done in 6.16s.

This is a mitigation for issue yarnpkg#2629.
In some cases two different packages could end up unpacking into the same cache folder.
Example yarnpkg#2629 (comment), package typescript is downloaded twice because yarn.lock has inconsistent entries.
This change prevents more than one package to be unpacked into the same cache folder.

This is not a final fix for yarnpkg#2629, there is a more specific bug in resolver that causes this internal inconsistency but I think fetcher should check that every package will be extracted in a unique folder anyway.

Test Plan:
- I'll add a unit test in the next PR when I'll be fixing the reason for the same package having 2 downloads
- Manual test plan
1. Check out yarnpkg#2629 (comment)
2. yarn install
```
yarn install v0.24.0-0
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
warning Pattern ["@angular/core@^2.0.0"] is trying to unpack in the same destination "/Users/bestander/Library/Caches/Yarn/v1/npm-@angular/core-4.0.0-rc.1-7f87b7696b407476e45d6d3c1880a50d5afbb6e3" as pattern ["@angular/core@4.0.0-rc.1","@angular/core@>=2.3.1 <5.0.0 || >=4.0.0-beta <5.0.0"]. This could result in a non deterministic behavior, skipping.
warning Pattern ["typescript@>=2.0.0 <2.2.0"] is trying to unpack in the same destination "/Users/bestander/Library/Caches/Yarn/v1/npm-typescript-2.2.1-4862b662b988a4c8ff691cc7969622d24db76ae9" as pattern ["typescript@2.2.1","typescript@>=2.1.4"]. This could result in a non deterministic behavior, skipping.
[3/4] πŸ”—  Linking dependencies...
warning "@angular/flex-layout@2.0.0-rc.1" has incorrect peer dependency "@angular/common@^2.2.3".
warning "@angular/flex-layout@2.0.0-rc.1" has incorrect peer dependency "@angular/core@^2.2.3".
warning "@angular/material@2.0.0-beta.2" has incorrect peer dependency "@angular/core@^2.3.0".
warning "@angular/material@2.0.0-beta.2" has incorrect peer dependency "@angular/common@^2.3.0".
warning "@angular/material@2.0.0-beta.2" has incorrect peer dependency "@angular/http@^2.3.0".
warning "@ngrx/effects@2.0.0" has incorrect peer dependency "@angular/core@^2.0.0".
warning "@ngrx/store@2.2.1" has incorrect peer dependency "@angular/core@^2.0.0".
warning "angular2-notifications@0.4.53" has incorrect peer dependency "@angular/core@^2.1.2".
warning "angular2-notifications@0.4.53" has incorrect peer dependency "@angular/common@^2.1.2".
warning "angular2-notifications@0.4.53" has incorrect peer dependency "@angular/platform-browser@^2.1.1".
warning "ng2-translate@5.0.0" has incorrect peer dependency "@angular/core@^2.0.0".
warning "ng2-translate@5.0.0" has incorrect peer dependency "@angular/http@^2.0.0".
warning "redux-batched-actions@0.1.5" has unmet peer dependency "redux@>=1.0.0".
[4/4] πŸ“ƒ  Building fresh packages...
✨  Done in 6.16s.
```
@bestander bestander requested a review from arcanis April 10, 2017 18:08
@arcanis
Copy link
Member

arcanis commented Apr 10, 2017

Don't we unpack tarballs into randomly-generated directories, before moving them to their final destination?

@bestander
Copy link
Member Author

bestander commented Apr 10, 2017 via email

@arcanis
Copy link
Member

arcanis commented Apr 10, 2017

Hm, I guess the rename would fail if both the source and the destination are located on the same filesystem, but yeah, it wouldn't help with the resolver issue.

@bestander bestander merged commit fb40251 into yarnpkg:master Apr 10, 2017
@bestander bestander changed the title Fixed concurrnet unpacks into the same folder Fixed concurrent unpacks into the same folder Apr 10, 2017
@FezVrasta
Copy link

Is this already published somewhere?

@bestander
Copy link
Member Author

Only in master branch now, the plan is to get it into 0.24.0 next week.

@FezVrasta
Copy link

Could it solve the error reported here?
lerna/lerna#752 (comment)

@bestander
Copy link
Member Author

It does seem related.
You can try nightly builds when there is a new one available https://yarnpkg.com/en/docs/nightly

@FezVrasta
Copy link

I ran:

git clone git@github.com:yarnpkg/yarn.git
cd yarn
yarn
yarn build-dist
cp -r build-dist /my/project/folder/yarn

Then inside the Dockerfile:

[...]
COPY yarn /opt/yarn
RUN ln -s /opt/yarn/bin/yarn /bin/yarn
[...]

But I get the same error, should I open a new issue?

@bestander
Copy link
Member Author

Yes, go ahead, with a repro steps please.
Also some instructions how to run the dockerfile from zero would be nice.

@FezVrasta
Copy link

FezVrasta commented Apr 11, 2017

I'm creating a repository/repro to make everything easier.
#3104

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants