fix(flutter): recover path dependency locations from pubspec.yaml - #4
Draft
pawelchcki wants to merge 1 commit into
Draft
fix(flutter): recover path dependency locations from pubspec.yaml#4pawelchcki wants to merge 1 commit into
pawelchcki wants to merge 1 commit into
Conversation
`flutter pub deps --json` reports path dependencies as source: "path" but omits the description carrying their location. The generated package_config therefore resolved an empty path for them, and the packages were silently dropped -- any workspace using a path dependency (vendored packages, a repo with several local packages, generated API clients) built without them and failed later on unresolved imports. Recover the location from the pubspec that declares the dependency, and use it only as a fallback when the JSON has no path of its own, so nothing changes for the cases that already worked. The lookup is a small indentation-aware scan rather than a YAML parse, since these scripts run with whatever bare python3 is on the host and cannot assume PyYAML. Applied at all three sites that resolve a path dependency: both copies of the package_config generator and the pubspec.lock synthesis.
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.
Problem
flutter pub deps --jsonreports path dependencies assource: "path"but omits the description that carries their location:{"name": "my_local_pkg", "source": "path", "kind": "direct", ...}The package_config generator resolves
path_valueto""for these, and theif path_value:guard then skipsadd_packageentirely — so the package is silently dropped. Any workspace using a path dependency (a vendored package, a monorepo with several local packages, generated API clients kept in-tree) builds without it and fails later on unresolved imports, with nothing pointing at the cause.Fix
Recover the location from the pubspec that declares the dependency, and use it only as a fallback when the JSON has no path of its own — so nothing changes for the cases that already work.
Applied at all three sites that resolve a path dependency: both copies of the package_config generator and the
pubspec.locksynthesis.Note on the parsing
The lookup is a small indentation-aware scan rather than a YAML parse. These scripts run with whatever bare
python3is on the host and cannot assume PyYAML is available. It only has to handle the shape pub itself requires:Happy to swap it for something stricter if you would rather take a dependency here.
Testing
Exercised against a real app with three path dependencies (two generated API clients and a vendored package). Before: all three missing from
package_config.jsonand the build fails on unresolved imports. After: all three resolve, and a full web build, test suite and analyze run pass.Marked draft — tell me how you would like the parsing handled and I will adjust before marking ready.