Turborepo "root task ... must not depend on" in CI
Turborepo refuses a dependency on a root task (//#task) when that root task itself calls turbo, because the root package is a dependency of every package and the chain would recurse. Turbo blocks it rather than loop.
What this error means
A turbo run step fails with a message that a root task such as "//#build" looks like it invokes turbo and may cause a loop, or that the root task must not depend on another task.
x root task //#build (turbo run build) looks like it invokes turbo and
might cause a loopCommon causes
A root task that calls turbo
The root package.json script for the task runs turbo run ...; depending on //#task would re-enter Turbo from the root, which is every package's dependency.
Another task depends on the recursive root task
A dependsOn: ["//#build"] points at a root task that fans back into Turbo, so the engine rejects the graph.
How to fix it
Make the root task not invoke turbo
- Change the root task so its script does not call
turbo(run the tool directly). - Then it is safe to add the root task to
tasksand depend on//#task. - Re-run the pipeline.
{
"scripts": { "build": "tsc -b" }
}Drop the dependency on the recursive root task
Remove the //#task entry from dependsOn if the root task must keep calling turbo, and orchestrate it from a separate command instead.
How to prevent it
- Keep root tasks free of
turbo runif other tasks depend on them. - Reserve
//#taskdependencies for leaf commands, not turbo wrappers. - Model fan-out with
^taskdependencies rather than root tasks.