Turborepo "--filter" Syntax Errors - Fix Selection in CI
Turborepo’s --filter selects packages by name, path, scope, or git range. A malformed pattern, an unfetched [ref] base, or shell quoting that eats the .../^ operators makes turbo select nothing or error.
What this error means
turbo run ... --filter=... errors on an invalid filter, or runs zero packages because a [origin/main] since-ref is not in the shallow CI clone. Deterministic for the pattern and checkout.
× invalid filter "...[origin/main]"
╰─▶ could not find git ref "origin/main" - is the history fetched?
# or: 0 packages selectedCommon causes
Since-ref not present in a shallow clone
A filter like ...[origin/main] diffs against a git ref. With CI’s default depth-1 checkout the base ref is absent, so the filter resolves to nothing or errors.
Malformed filter pattern
Misusing the operators - ^ (dependents), ... (dependencies/changed), {path} globs, @scope/* - yields an invalid filter turbo rejects.
Shell quoting strips operators
Unquoted ... or {} can be altered by the shell, so turbo receives a different string than intended.
How to fix it
Fetch history for since-ref filters
Provide full history so [ref] resolves, and quote the filter so the shell leaves it intact.
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- run: turbo run build --filter="...[origin/main]"Use correct filter operators
Combine name/scope, path, dependency, and changed selectors deliberately.
turbo run test --filter=@acme/web # one package
turbo run build --filter=@acme/web... # package + its dependencies
turbo run lint --filter=...@acme/ui # ui + everything depending on it
turbo run build --filter="{./apps/*}[HEAD^1]" # changed packages under apps/How to prevent it
- Use
fetch-depth: 0whenever a filter uses a[git-ref]base. - Quote
--filtervalues so the shell does not alter operators. - Validate a filter with
turbo run <task> --filter=... --dryfirst.