fix(wasix): don't inherit a dependency's entrypoint over the root's own commands - #6872
Open
Arshia001 wants to merge 2 commits into
Open
fix(wasix): don't inherit a dependency's entrypoint over the root's own commands#6872Arshia001 wants to merge 2 commits into
Arshia001 wants to merge 2 commits into
Conversation
…wn commands `resolve_package` walked the whole dependency graph looking for an entrypoint whenever the root package didn't declare one, so a dependency that declares an entrypoint would win over the root package's own commands. `wasmer/anybuild` depends on `wasmer/bash`, which declares `entrypoint = "bash"`, so it ran bash instead of anybuild. Only let a command-less root inherit an entrypoint from a dependency. This also makes the existing "root package's only command" fallback reachable, which it previously wasn't whenever any dependency declared an entrypoint. Fixes #6870 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes WASIX package entrypoint resolution so a dependency’s entrypoint can no longer override (or “hijack”) the root package’s own commands when the root has commands but does not explicitly declare an entrypoint, addressing the behavior reported in #6870.
Changes:
- Gate dependency-entrypoint inheritance on the root package having zero commands.
- Preserve the existing “root package’s only command” fallback by making it reachable again when the root has exactly one command.
- Add regression tests covering (a) multi-command roots and (b) single-command roots against dependency entrypoints.
Comment on lines
+800
to
+804
| // A package that ships commands of its own must resolve to one of them, so | ||
| // only a command-less root may inherit an entrypoint from a dependency. | ||
| // Otherwise a dependency like wasmer/bash, which declares an entrypoint, | ||
| // would hijack the root package's own commands. | ||
| let may_inherit_entrypoint = dependency_graph.root_info().commands.is_empty(); |
Comment on lines
+2125
to
+2131
| // Ambiguous between "anybuild" and "shipit", but never "bash". | ||
| assert_ne!( | ||
| resolution.package.entrypoint.as_deref(), | ||
| Some("bash"), | ||
| "the entrypoint must not come from a dependency when the root has \ | ||
| commands of its own", | ||
| ); |
Assert the exact `None` the 2+ command case is supposed to produce, so the test also fails if the resolver starts guessing between the root's own commands, and stop implying a root with commands always resolves to one of them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolve_packagewalked the whole dependency graph looking for an entrypoint whenever the root package didn't declare one, so a dependency's entrypoint would win over the root package's own commands.wasmer/anybuilddeclares no entrypoint and depends onwasmer/bash, which declaresentrypoint = "bash"— so it ran bash instead of anybuild.Only a command-less root may now inherit an entrypoint from a dependency. That also makes the existing "root package's only command" fallback reachable, which it previously wasn't whenever any dependency declared an entrypoint.
Behaviour by case:
None, i.e. an error rather than silently running the wrong binaryNot a recent regression — the inheritance loop dates to the original resolver (2023). It surfaced when
wasmer/bashaddedentrypoint = "bash"in 1.0.21.Two regression tests added. Full
wasmer-wasixlib suite passes (225).Fixes #6870
🤖 Generated with Claude Code