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

Fix install --production not installing used packages, fixes #2468, #2263 #2537

Merged
merged 2 commits into from
Jan 25, 2017

Conversation

blexrob
Copy link
Contributor

@blexrob blexrob commented Jan 23, 2017

Summary

When installing only production packages using yarn install --production, the packagehoister sometimes ignores packages that are actually used. This can happen when an ignored package is deduped with another ignored package. If so, the isIgnored function won't pick up when the parent of the second package becomes non-ignored due to a dependency that is processed later. This is the cause of bug #2468 and bug #2263 (and probably #2421 too, though I haven't tested that one)

This happens with roughly this dependency tree:
dev A -> B (1)
dev A -> C -> B (2)
normal D -> E -> F -> C (3)

  1. B is hoisted to the root, with isIgnored calling parent A.
  2. B(2) is deduped to B(1). But, because C is also ignored at this point, the isIgnored function of B isn't changed.
  3. A non-ignored dependency on C is added, and C is marked as non-ignored. The isIgnored function of B(1) won't see this change.

Changing the isIgnored function to call both the existing and the deduped isIgnored will cause a stack overflow to happen in the test of 2263, so that solution is out.

To fix this, I have opted to remove the isIgnored function calls, and replace it with a 2 booleans, one to keep the current ignore status and one note wither inheritance is allowed (so it works just like the function call solution). With a processing step after seeding the hoister will then mark all dependencies of non-ignored packages as non-ignored too.

Test plan

I have enabled the test from #2263, it runs without errors. Also, I have run a production-only install on the package.json from #761 (comment), and abbrev is installed there too. yarn run test also finishes without any failures.

The algorithm for marking the hoistmanifests will only visit non-ignored ones, and only once, so can't lead to an infinite loop.

@havenchyk
Copy link

@bestander could you please take a look? I know you have a queue of PRs with different priority, but this one is 2 days as ready 😄

@bestander
Copy link
Member

Oh lovely, will have a look today

Copy link
Member

@bestander bestander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the fix!
Could you fix just a few style nits and then let's merge it!

@@ -793,7 +793,7 @@ test.concurrent('a subdependency of an optional dependency that fails should be
});

// disabled while fix is not merged
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, missed that one


_propagateNonIgnored() {
//
const tovisit: Array<HoistManifest> = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toVisit - according to code style in other places

//
const depinfo = this._lookupDependency(info, depPattern);

//
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaces and // serve something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping the code density in line with the rest of the code, nothing more. No problem to remove them.

@bestander bestander merged commit e957e22 into yarnpkg:master Jan 25, 2017
@bestander
Copy link
Member

@blexrob, great job!
Let's now see if it fixes all the issues reported.

@SimenB
Copy link
Contributor

SimenB commented Jan 26, 2017

Oh, awesome! I have 2 projects at work that failed earlier, I'll give this a whirl in a couple of hours

@havenchyk
Copy link

Works fine in my cases, great job! Doesn't fail anymore

@SimenB
Copy link
Contributor

SimenB commented Jan 26, 2017

master now works with all 3 of my earlier failing test cases! wooo 🎉
Any chance of a backport? If not, what's the ETA of 0.20 stable?

@bestander
Copy link
Member

I was planning to release 0.20 on Monday next week.

@bestander
Copy link
Member

If you want to send a PR to cherry-pick this into 0.19-stable, I'll merge it.

@blexrob
Copy link
Contributor Author

blexrob commented Jan 26, 2017

@bestander Thanks! I have just tested #1808, and the failure there seems to be gone, too.

ConAntonakos pushed a commit to ConAntonakos/yarn that referenced this pull request Jan 30, 2017
…2468, yarnpkg#2263  (yarnpkg#2537)

* Explicitly mark ignored deps of non-ignored packages as non-ignored (yarnpkg#761, yarnpkg#2468, yarnpkg#2263)

* Fix style nits
@beheh beheh mentioned this pull request Feb 1, 2017
SimenB added a commit to finn-no/node-docker that referenced this pull request Feb 3, 2017
They've fixed the issue (finally!)

Ref yarnpkg/yarn#2537
@philstrong
Copy link

Upgrading to 0.21.3 fixed my issue for for-in (for-own)

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.

5 participants