Skip to content

Regression in 7.4.0: --order-dependents now fails on graphs with dev_dependency cycles that were previously tolerated #1003

@dennishenle

Description

@dennishenle

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds attentionOP has responded and the issue needs looking at again.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions