Upgrading from melos 7.3.0 to 7.4.x / 7.5.x causes melos exec --order-dependents (and any script that sets orderDependents: true, including the common build_runner recipe) to hard-fail with
🚨 1 cycles in dependencies found:
[ A -> B -> C ]
Environment
melos --version: 7.4.1 (also reproduces with 7.4.0 and 7.5.1)
- Dart SDK: 3.10+
- OS: macOS 15 (also reported internally on Linux CI)
- Workspace: Pub workspace (Melos 7.x), root
pubspec.yaml
Minimal reproduction
The scenario below mirrors a very common Dart/Flutter monorepo layout: a shared
test_helpers package that imports the real types from every feature package
so it can expose mocks and pump helpers, and each feature package pulling
test_helpers back in via dev_dependencies to use those helpers in its own
widget/unit tests.
Three packages in a workspace:
# packages/test_helpers/pubspec.yaml
name: test_helpers
resolution: workspace
dependencies:
ui: 0.1.0 # needs the real types to mock
auth: 0.1.0
# packages/ui/pubspec.yaml
name: ui
resolution: workspace
dev_dependencies:
test_helpers: 0.1.0 # uses the shared mocks/pump helpers in widget tests
# packages/auth/pubspec.yaml
name: auth
resolution: workspace
dependencies:
ui: 0.1.0
dev_dependencies:
test_helpers: 0.1.0 # same pattern, closes a second cycle
The test_helpers ↔ ui and test_helpers ↔ auth edge pairs each form a cycle
through dev_dependencies. In a real monorepo this pattern repeats for every
feature package (banking, contacts, …), so the graph ends up with many
such cycles.
Running:
melos exec --order-dependents -- echo hello
Observed behaviour
- On
7.3.0: command runs successfully in every package.
- On
7.4.0+: fails immediately with
🚨 1 cycles in dependencies found:
[ test_helpers -> ui -> auth ]
Expected behaviour
Treat cycles involving only dev_dependencies as non-fatal (or just ignore dev_dependencies when computing execution order), since dev_dependencies aren't transitive in pub and therefore don't actually impose an ordering constraint on code generation or test execution across packages.
Request
Document the change as BREAKING in the 7.4.0 changelog and recommend pinning to 7.3.0 until the graph is a DAG.
Workaround
Pinning melos: 7.3.0 in the root pubspec.yaml restores the previous behaviour. This is what we've done for now.
Upgrading from
melos 7.3.0to7.4.x/7.5.xcausesmelos exec --order-dependents(and any script that setsorderDependents: true, including the commonbuild_runnerrecipe) to hard-fail withEnvironment
melos --version:7.4.1(also reproduces with7.4.0and7.5.1)pubspec.yamlMinimal reproduction
The scenario below mirrors a very common Dart/Flutter monorepo layout: a shared
test_helperspackage that imports the real types from every feature packageso it can expose mocks and pump helpers, and each feature package pulling
test_helpersback in viadev_dependenciesto use those helpers in its ownwidget/unit tests.
Three packages in a workspace:
The
test_helpers ↔ uiandtest_helpers ↔ authedge pairs each form a cyclethrough
dev_dependencies. In a real monorepo this pattern repeats for everyfeature package (
banking,contacts, …), so the graph ends up with manysuch cycles.
Running:
Observed behaviour
7.3.0: command runs successfully in every package.7.4.0+: fails immediately withExpected behaviour
Treat cycles involving only
dev_dependenciesas non-fatal (or just ignoredev_dependencieswhen computing execution order), sincedev_dependenciesaren't transitive in pub and therefore don't actually impose an ordering constraint on code generation or test execution across packages.Request
Document the change as BREAKING in the 7.4.0 changelog and recommend pinning to
7.3.0until the graph is a DAG.Workaround
Pinning
melos: 7.3.0in the rootpubspec.yamlrestores the previous behaviour. This is what we've done for now.