pub
pub copied to clipboard
`[pub get]` too many dependencies
Is there an existing issue for this?
- [x] I have searched the existing issues
- [X] I have read the guide to filing a bug
Use case
As shown in the figure, upgrading so many dependencies in the root package. When there is base package upgrade,It's needed to try the pub get and fix the package dependencies one by one, even some of the package are not used in current platform.
image is too big, you can rename the third_party_dependencies.txt to third_party_dependencies.dot and run dot -Tsvg -o third_party_dependencies.dot dot -Tsvg -o third_party_dependencies.svg
generated it.
Proposal
-
Add
futter pub get --platforms
command to obtain dependencies from different platforms, reducing the number of dependencies, so that unused platforms should not broken currently used platforms. -
Add
flutter search {package} {package_version}
to query the dependencies of the specified library.
Does't can also support query parents package in the rootPackage. When change one of the package, can be clearly known how many packages will be affect.
flutter pub show --name=childPackage parentDeps --rootPackage={rootPackage}
childPackage -->parentA-->parentB
parentA-->parentC
parentC --->parentD
Add futter pub get --platforms command to obtain dependencies from different platforms, reducing the number of dependencies, so that unused platforms should not broken currently used platforms.
This sounds like a duplicate of this request: https://github.com/dart-lang/pub/issues/3969 . We have no current plans for such a feature.
Addflutter search {package} {package_version} to query the dependencies of the specified library.
You can get a dependency tree of your packages with dart pub deps
- currently we don't have a way to show this tree for just a single package, opened https://github.com/dart-lang/pub/issues/3991 for this.
For upgrading many packages at once, have you tried: dart pub upgrade --major-versions
?
Our project has hundreds of packages(Actually, there are over 500 packages), the dart pub upgrade not work for it, and there are also sub packages in the project that referenced by path (208 packages). Once encountering a major version error, it automatically terminated, upgrading such a project is a relatively great work.
the dart pub upgrade not work for it
Can you describe what goes wrong?, maybe we can improve it.
Below is some of the errors, we can see it blocked when one of the packages conflicted. when resolved this package, we need to start flutter upgrade
again until all the package conflict resolved. The problem is our project has too many dependencies, it hard to known which version should be upgrade to at the first time, use this method need to try many times many time flutter upgrade
commands.
SLVR: derived: native_extension_flutter_plugin from git
SLVR: conflict: every version of platform_sdk from path depends on meta 1.8.0
SLVR: derived: meta 1.8.0
SLVR: conflict: every version of flutter_driver from sdk depends on meta 1.9.1
SLVR: ! not meta 1.9.1 is satisfied by meta 1.8.0
SLVR: ! which is caused by "every version of platform_sdk from path depends on meta 1.8.0"
SLVR: ! thus: flutter_driver from sdk is incompatible with platform_sdk from path
SLVR: ! platform_sdk from path is satisfied by platform_sdk from path
SLVR: ! which is caused by "mobile_connected depends on platform_sdk from path"
SLVR: ! thus: flutter_driver from sdk is forbidden
SLVR: ! flutter_driver from sdk is satisfied by flutter_driver from sdk
SLVR: ! which is caused by "mobile_connected depends on flutter_driver from sdk"
SLVR: ! thus: version solving failed
SLVR: Version solving took 0:01:10.237182 seconds.
| Tried 1 solutions.
FINE: Resolving dependencies finished (1:10.244s).
ERR : Because every version of flutter_driver from sdk depends on meta 1.9.1 and every version of platform_sdk from path depends on meta 1.8.0, flutter_driver
| from sdk is incompatible with platform_sdk from path.
| So, because mobile_connected depends on both platform_sdk from path and flutter_driver from sdk, version solving failed.
FINE: Exception type: SolveFailure
FINE: package:pub/src/solver/version_solver.dart 329:5 VersionSolver._resolveConflict
| package:pub/src/solver/version_solver.dart 140:27 VersionSolver._propagate
| package:pub/src/solver/version_solver.dart 104:11 VersionSolver.solve.<fn>
| ===== asynchronous gap ===========================
| dart:async Future.catchError
| package:pub/src/utils.dart 113:52 captureErrors.wrappedCallback
| package:stack_trace Chain.capture
| package:pub/src/utils.dart 126:11 captureErrors
| package:pub/src/command.dart 198:13 PubCommand.run
| package:args/command_runner.dart 212:27 CommandRunner.runCommand
| package:dartdev/dartdev.dart 226:30 DartdevRunner.runCommand
| package:args/command_runner.dart 122:25 CommandRunner.run.<fn>
| dart:async new Future.sync
| package:args/command_runner.dart 122:14 CommandRunner.run
| package:dartdev/dartdev.dart 58:29 runDartdev
| /opt/s/w/ir/x/w/sdk/pkg/dartdev/bin/dartdev.dart 11:9 main
---- End log transcript ----
IO : Writing 9618918 characters to text file /Users/qxz3ln7/.pub-cache/log/pub_log.txt.
MSG : Logs written to /Users/qxz3ln7/.pub-cache/log/pub_log.txt.
Since there are hundreds of packages, we need lock the basic packages dependency about the new flutter version firstly. Then search the parent deps to decide which package should be upgrade or overrides. If there is tools could automatic processing those package dependencies and give some recommendation which packages should be upgrade or override, the work will be more easy. e.g.
flutter pub upgrade --basic-packages={ meta: 18.0, collection: 1.7.1, analyzer: '^5.0.0'} --package-root={package-root} --platforms={platforms} --custom-packages={custom packages}
The command base on the basic package list to upgrade the project, and use the platform parameter to ignore give some override suggestions when there is conflict for third party package that the developer could not modify the source code directly, the custom packages means that owned by the developers and they can fix it for any conflicts.
The out pub will show a report for upgrade
- Suggest override list
- Minimum conflict package list for third party that must be fixed
- Conflict custom package list that owned by developers