Skip to content
This repository was archived by the owner on Aug 11, 2022. It is now read-only.

Don't try to install known-uninstallable opt deps that are in shrinkwraps - #13692

Closed
iarna wants to merge 11 commits into
release-nextfrom
iarna/shrinkwrap-opt-not-installable
Closed

iarna wants to merge 11 commits into
release-nextfrom
iarna/shrinkwrap-opt-not-installable

Conversation

@iarna

@iarna iarna commented Aug 17, 2016

Copy link
Copy Markdown
Contributor

The commits here will be rolled up a bit before merge.

Ordinarily, if an optional dep fails the arch/cpu checks then we never try to extract it or install it.

But if an optional dep is in an npm-shrinkwrap.json file then it would get injected into the tree without checking instability–this fixes that.

In a perfect world we would do this step in inflate-shrinkwrap. Adding that there will be somewhat involved however as it currently has no facility for skipping a dependency. We could just skip the opt dep that can't work but what we need it to do is ALSO skip any of its transitive deps as well. Worse, it might be a non-optional transitive dep of an optional dep that failed and we have to go back and remove the entire tree associated with the optional dep. Fortunately this is already implemented elsewhere…

So instead I've implemented this by doing the check prior to running any actions. The action running stage already has facilities to deal with failing optional deps and by hooking this as a prerequisite to ANY actions, it means it will happen before the very first one, which is fetch. This means performance-wise it should be roughly equivalent to doing this in inflate-shrinkwrap and it saves us from duplicating the optional-dep-failing code.

@iarna
iarna force-pushed the iarna/shrinkwrap-opt-not-installable branch 4 times, most recently from 3a385ea to 2892ea6 Compare August 17, 2016 21:53
Comment thread lib/install/actions.js Outdated
}
}
function thenRunAction () {
pkg.knownInstallable = true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do you need andMarkInstallable at all here? It looks like both code paths hit thenRunAction invariably. Alternately, why is this in thenRunAction? In the path that skips andMarkInstallable, pkg.knownInstallable is already true.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a good question…

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The answer is: This wasn't supposed to still be in thenRunAction

@zkat

zkat commented Aug 24, 2016

Copy link
Copy Markdown
Contributor

LGTM! Couple of nits you're free to ignore, otherwise 🐑 🎉

@iarna
iarna force-pushed the iarna/shrinkwrap-opt-not-installable branch from fb872ed to 60100c9 Compare August 30, 2016 22:58
iarna added 8 commits August 30, 2016 15:59
We were doing a weird thing where we used a package.json field _installable_
to check to see if we'd checked for platform compatibility, and if not did
so.  But this was the only place that was ever done so there was no reason to
implement it in such an obfuscated manner.

Instead it now just directly checks and then records that its done so on the
node object with `knownInstallable`.  This is useful to know because modules
expanded via shrinkwrap don't go through this– `inflateShrinkwrap` does not
currently have any rollback semantics and so checking this sort of thing there
is unhelpful.

PR-URL: #13692
Credit: @iarna
Reviewed-By: @zkat
@iarna
iarna force-pushed the iarna/shrinkwrap-opt-not-installable branch from 60100c9 to 1a696cb Compare August 30, 2016 23:00
iarna added 3 commits August 30, 2016 16:57
Modules that came into the tree via shrinkwrap won't have had this
determined in advance so we check here and take advantage of the
optional rollback semantics to skip them.

Plus if it was a regular dependency we can just fail out now instead of
trying and failing to install the dep.

Fixes: #13394
PR-URL: #13692
Credit: @iarna
Reviewed-By: @zkat
@iarna
iarna force-pushed the iarna/shrinkwrap-opt-not-installable branch from 1a696cb to 97b81de Compare August 30, 2016 23:58
@coveralls

Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling 97b81de on iarna/shrinkwrap-opt-not-installable into * on release-next*.

@iarna

iarna commented Sep 2, 2016

Copy link
Copy Markdown
Contributor Author

Landed in release-next!

@iarna iarna closed this Sep 2, 2016
zkat pushed a commit that referenced this pull request Sep 8, 2016
zkat pushed a commit that referenced this pull request Sep 8, 2016
zkat pushed a commit that referenced this pull request Sep 8, 2016
zkat pushed a commit that referenced this pull request Sep 8, 2016
zkat pushed a commit that referenced this pull request Sep 8, 2016
zkat pushed a commit that referenced this pull request Sep 8, 2016
zkat pushed a commit that referenced this pull request Sep 8, 2016
We were doing a weird thing where we used a package.json field _installable_
to check to see if we'd checked for platform compatibility, and if not did
so.  But this was the only place that was ever done so there was no reason to
implement it in such an obfuscated manner.

Instead it now just directly checks and then records that its done so on the
node object with `knownInstallable`.  This is useful to know because modules
expanded via shrinkwrap don't go through this– `inflateShrinkwrap` does not
currently have any rollback semantics and so checking this sort of thing there
is unhelpful.

PR-URL: #13692
Credit: @iarna
Reviewed-By: @zkat
zkat pushed a commit that referenced this pull request Sep 8, 2016
zkat pushed a commit that referenced this pull request Sep 8, 2016
zkat pushed a commit that referenced this pull request Sep 8, 2016
Modules that came into the tree via shrinkwrap won't have had this
determined in advance so we check here and take advantage of the
optional rollback semantics to skip them.

Plus if it was a regular dependency we can just fail out now instead of
trying and failing to install the dep.

Fixes: #13394
PR-URL: #13692
Credit: @iarna
Reviewed-By: @zkat
@zkat zkat mentioned this pull request Sep 22, 2016
4 tasks done
@iarna
iarna deleted the iarna/shrinkwrap-opt-not-installable branch December 1, 2016 00:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants