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(arborist): omit failed optional dependencies from installed deps,… #8177

Open
wants to merge 3 commits into
base: latest
Choose a base branch
from

Conversation

zkat
Copy link
Contributor

@zkat zkat commented Mar 22, 2025

… but keep them 'in the tree'

Fixes: #4828
Fixes: #7961
Replaces: #8127
Replaces: #8077

When optional dependencies fail, we don't want to install them, for whatever reason. The way this "uninstallation" is done right now is by simply removing the dependencies from the ideal tree during reification.

Unfortunately, this means that what gets saved to the "hidden lockfile" is the edited ideal tree as well, and when NPM runs next, it'll use that when regenerating the "real" package-lock.

This PR tags failed optional deps such that they're still added to the "trash list" (and thus have their directories cleaned up by the reifier), but prevents Arborist from removing them altogether from the ideal tree (which is usually done by setting their parent to null, making them unreachable, and letting them get GC'd).

PS: It's Friday, this is what I managed to get done together. I'm making this a draft PR for now so folks can look at it, but I want to make sure both reifiers work well, fix some messaging issues, and clean stuff up (I'm pretty sure I'm guarding ideallyInert in more places than I need to, because I was trying to find the right spot). Still, feel free to talk about the approach. I'll get back to this on Monday.

PPS: also hi

@zkat
Copy link
Contributor Author

zkat commented Mar 22, 2025

Pretty sure all the test failures are just the tests needing to be updated because the nodes themselves don't go anywhere anymore.

@zkat
Copy link
Contributor Author

zkat commented Mar 22, 2025

oh no it didn't quite work how embarrassing. Oh well see you monday :P

@zkat
Copy link
Contributor Author

zkat commented Mar 22, 2025

probably need to fix load-actual-tree too or something.

@zkat
Copy link
Contributor Author

zkat commented Mar 24, 2025

image

[cackle] It's aliiiiive!

Now I just need to do see about round-tripping it.

zkat and others added 3 commits March 26, 2025 16:05
… but keep them 'in the tree'

Fixes: npm#4828
Fixes: npm#7961
Replaces: npm#8127
Replaces: npm#8077

When optional dependencies fail, we don't want to install them, for whatever reason. The way
this "uninstallation" is done right now is by simply removing the dependencies from the ideal tree
during reification.

Unfortunately, this means that what gets saved to the "hidden lockfile" is the edited ideal tree
as well, and when NPM runs next, it'll use that when regenerating the "real" package-lock.

This PR tags failed optional deps such that they're still added to the "trash list" (and thus have
their directories cleaned up by the reifier), but prevents Arborist from removing them altogether
from the ideal tree (which is usually done by setting their parent to `null`, making them unreachable,
and letting them get GC'd).
@zkat zkat marked this pull request as ready for review March 26, 2025 23:30
@zkat zkat requested a review from a team as a code owner March 26, 2025 23:30
@zkat
Copy link
Contributor Author

zkat commented Mar 26, 2025

Alright, this works now. No more thrashing, and the test suite is passing. There's 6 lines missing coverage, but as we talked about, I'll let you take care of it from here, @owlstronaut :)

nick1udwig added a commit to hyperware-ai/hyperdrive that referenced this pull request Mar 27, 2025
see fix implemented here, discussed at:
npm/cli#4828 (comment)

soon there will be a PR to address so we may be able to remove
these optional dependencies once this PR is merged:
npm/cli#8177
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants