-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Fix an issue in package hoisting #2164
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
Conversation
Existing tests are failing |
Yep I know. The test |
You probably should just add a new test with your example and test that all expected folders are in place.
We cache network requests, so no need to worry about them. |
@bestander It won't fail on OSX. So it's not very reliable. |
We have a few tests that are skipped on some platforms.
Clout CI run Windows and Linux, so it should be fine.
An isolated custom test is always better but real world examples are good
too
…On Wed, 7 Dec 2016 at 12:42, Mathias Vestergaard ***@***.***> wrote:
@bestander <https://github.com/bestander> It won't fail on OSX. So it's
not very reliable.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2164 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACBdWLNPLUjJcOunV8r5PUgZz8HustzZks5rFqmogaJpZM4LFbCu>
.
|
Fair enough. I'll add a test later. |
It is ok to do it in steps.
If you add a test that fails properly we can merge it and then do a new PR
that fixes the issue based on the test
…On Wed, 7 Dec 2016 at 12:51, Mathias Vestergaard ***@***.***> wrote:
Fair enough. I'll add a test later.
Looking into whether the hoisting should factor ignored dependencies test
should be refactored is not a task I feel I have enough knowledge of the
internals to do however.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2164 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACBdWKET2Z6sGtJzl5lF9USvn1aFHQdMks5rFqvmgaJpZM4LFbCu>
.
|
@bestander do I need to do anything special to do an actual install in tests?
I tried passing Here's the test for reference: test.concurrent('issue #2142 regression test',
(): Promise<void> => {
return runInstall({production: true}, 'install-issue-2142-regression', async (config) => {
assert.ok(await fs.exists(path.join(config.cwd, 'node_modules', 'deep-extend')));
assert.ok(await fs.exists(path.join(config.cwd, 'node_modules', 'ini')));
assert.ok(await fs.exists(path.join(config.cwd, 'node_modules', 'strip-json-comments')));
});
}); |
@mvestergaard, could you commit it here? |
@bestander Done |
For tests we cache http requests in tests/fixtures/request-cache so that our CI does not depend on network when running them. |
Ok that helped on my machine. It fails on CI too though. |
I was having this issue as well. Just tested your fix and it worked for me on Windows 10. Optional dependency I nuked all caches and my entire yarn installation before and after applying the patch to confirm that it was this patch that resolved my issue. |
@bestander I've modified the |
When a dependency is ignored in a dependency branch where the parent is ignored it is also sometimes ignored in branches where it is still required
We can't use yarn just yet on travis until an upstream fix is landed for yarnpkg/yarn#2164
@bestander Have you had a chance to look at this yet? Feedback would be appreciated. |
@mvestergaard will look right now, thanks a lot! |
|
||
// problem occuring due to optional dependency incompatible with os, in this case fsevents | ||
// if issue exists, this will not fail on OSX | ||
test.concurrent('issue #2142 regression test', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not 100% sure when we want to split all tests into separate files.
How about moving it into integration.js for now?
Could you also give it a descriptive name so that people don't go to the web searching what issue 2142 was about?
@bestander Done. Having it in it's own file was mostly for my own convenience, so fair point. |
!await fs.exists(path.join(config.cwd, 'node_modules', 'c')), | ||
// c is only depended upon by d in version 2.0.0, so it should be hoisted | ||
assert.equal( | ||
(await fs.readJson(path.join(config.cwd, 'node_modules', 'c', 'package.json'))).version, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is the idea of Yarn - it keeps packages hoisting deterministic between normal and production build.
The test checked that hoisting of C should be stable and I think it was correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, my attempt at a fix probably won't work.
The root problem from what I could find is when you have two different packages with dependencies required by both. When one of the parent packages are ignored, either by --production
flag or being incompatible, it ends up skipping the shared dependencies because the ignored package goes through the hoisting logic, and the dependency thereby end up being skipped due to being seen as a duplicate, even though it hasn't been installed at all.
Let's undo your code change and merge your test as disabled in the meantime.
We'll come up with a fix in the next few days.
…On Mon, 12 Dec 2016 at 19:09, Mathias Vestergaard ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In __tests__/commands/install/integration.js
<#2164>:
> assert.ok(
!await fs.exists(path.join(config.cwd, 'node_modules', 'b')),
);
- assert.ok(
- !await fs.exists(path.join(config.cwd, 'node_modules', 'c')),
+ // c is only depended upon by d in version 2.0.0, so it should be hoisted
+ assert.equal(
+ (await fs.readJson(path.join(config.cwd, 'node_modules', 'c', 'package.json'))).version,
In that case, my attempt at a fix probably won't work.
The root problem from what I could find is when you have two different
packages with dependencies required by both. When one of the parent
packages are ignored, either by --production flag or being incompatible,
it ends up skipping the shared dependencies because the ignored package
goes through the hoisting logic, and the dependency thereby end up being
skipped due to being seen as a duplicate, even though it hasn't been
installed at all.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2164>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACBdWMnNbKLm0A1fwgkEpdp77QAFrykCks5rHZvggaJpZM4LFbCu>
.
|
@bestander I reverted the changes, and set the new test to |
* Fix an issue in package hoisting When a dependency is ignored in a dependency branch where the parent is ignored it is also sometimes ignored in branches where it is still required * Move test into integration.js and rename the test * Revert code changes and skip new test for now Conflicts: __tests__/commands/install/integration.js __tests__/fixtures/install/install-should-not-skip-required-shared-deps/package.json
Summary
This is an attempt to fix #2142
Using this package.json
Should create a scenario along the lines of this (on any platform except OSX):
My findings from debugging is that this happens because of the following:
It seems like what happens is that
rc
is ignored in thefsevents
branch.This causes
get-proxy#rc
to be removed from the tree in the methodhoist@283
:this.tree.delete(key);
and when it looks at the dependencydeep-extend
in_seed@141
it will skip it becauseget-proxy#rc
was removed from the tree:get-proxy#rc
is removed from the tree due to:With this change, installed packages align with installiation through npm.
npm install
andnpm prune
yield no changes.At this time, this seems to break the test
hoisting should factor ignored dependencies
.Test plan
I have not been able to replicate the original scenario in a test.
I've made multiple attempts including https://github.com/mvestergaard/yarn/commit/9521157ace19bb4d42240532091d8b5402b05ef5