Skip to content

Needless rebuilds when run with or without --workspace #9114

@ijackson

Description

@ijackson
Contributor

Problem

cargo rebuilds things if I switch between cargo build and cargo build --workspace.

Steps

  1. git clone https://salsa.debian.org/iwj/otter
  2. cd otter
  3. git checkout c9b5a88d7a33a6e1eac22736be0a38c6815e1706
  4. cargo build --workspace
  5. cargo build

To repeat, restarting from after step 4 or 5:

  1. touch src/updates.rs
  2. as above
  3. as above

Expected behaviour

The whole workspace including the toplevel package otter was built in step 4, so step 5 should not build anything and should be very quick.

Actual behaviour

cargo rebuilds otter (including library and binaries) in step 5 (about six seconds on my laptop in a repeated test)

Notes

Output of cargo version:

cargo 1.51.0-nightly (783bc43c6 2021-01-20)

Activity

ijackson

ijackson commented on Jan 30, 2021

@ijackson
ContributorAuthor

@rustbot modify labels +A-rebuild-detection +A-workspaces

rustbot

rustbot commented on Jan 30, 2021

@rustbot
Collaborator

Error: The feature relabel is not enabled in this repository.
To enable it add its section in the triagebot.toml in the root of the repository.

Please let @rust-lang/release know if you're having trouble with this bot.

ijackson

ijackson commented on Jan 30, 2021

@ijackson
ContributorAuthor

I have been attempting to work around this and the behaviours I'm seeing make me think it may be related to #4463.

ijackson

ijackson commented on Jan 30, 2021

@ijackson
ContributorAuthor

A workaround in my environment is to always pass --workspace (plus, usually, suitable -p options) to cargo.

ehuss

ehuss commented on Jan 31, 2021

@ehuss
Contributor

Yea, this is expected behavior in that the features chosen depend on which packages are being built. Closing as a duplicate of #4463.

There are other workarounds such as a common package that forces the same features (see rustc-workspace-hack as an example).

added a commit that references this issue on Dec 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ehuss@ijackson@rustbot

        Issue actions

          Needless rebuilds when run with or without --workspace · Issue #9114 · rust-lang/cargo