Skip to content

ls --affected accuracy issue when root package.json or turbo.json changes #10869

@0xb4lamx

Description

@0xb4lamx

Verify canary release

  • I verified that the issue exists in the latest Turborepo canary release.

Link to code that reproduces this issue

https://github.com/0xb4lamx/turborepo-ls-affected-accuracy-issue

Which canary version will you have in your reproduction?

2.5.6

Expected behavior

on changes to root package.json:

  • turbo ls --affected should only list packages that are actually affected by the change.

Note: According to Turborepo 2.1 release note, turbo ls --affected --output=json was introduced as a recommended replacement for turbo build --dry=json when you only need to retrieve a list of changed packages.

Actual behavior

on any random change to the root package.json:

  • turbo ls --affected shows ALL packages as affected regardless of the change.
  • turbo build --dry-run=json shows clear cache hit! (correct actual+expected behavior)

To Reproduce

  1. Create a simple Turborepo with any packages:

    npx create-turbo@latest test-repo
    cd test-repo
  2. Build to create initial cache:

    pnpm install
    pnpm turbo build  # This creates the cache that we'll test against
  3. Make a minimal change to root package.json:

    # Add a space before the opening brace on line 1
    sed -i '' '1s/{/ {/' package.json
    # Or manually edit.  (add any random white space)
  4. Check what turbo ls --affected shows:

    pnpm turbo ls --affected

    Result: Shows ALL packages as affected ❌

  5. Check what turbo build --dry=json shows:

    pnpm turbo build --dry=json | jq -c '. as $root | .tasks[] | { taskId, cache: .cache.status }'

    Result: Shows ALL packages as "cache":"HIT"

Additional context

this GH action job run could easily showcase the issue:

Image

more details: https://github.com/0xb4lamx/turborepo-ls-affected-accuracy-issue/actions/runs/17892941470/job/50875748218.

I think --affected need to be more intelligent when handling changes to the root package.json (and turbo.json). A change in those files should not automatically mark all packages as affected unless the change actually impacts them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions