From b58bf7abeb83e0293ff9fe03250c19f34a35f4f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bombo?= Date: Tue, 24 Mar 2026 10:43:20 -0500 Subject: [PATCH] build: Don't fail `cargo check` on a dirty tree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `cargo check` was introduced in 3f1533a to check that Cargo.lock is in sync with Cargo.toml. However, if there are uncommitted changes in the working tree, the current invocation will immediately fail because of the `git diff` call, which is frustrating for local development. As it turns out, `cargo clippy` is a superset of `cargo check`, so we can simply pass `--locked` to `cargo clippy` to detect Cargo.lock issues. This is tested with the following change: diff --git a/src/agent/Cargo.lock b/src/agent/Cargo.lock index 96b6c676d..e1963af00 100644 --- a/src/agent/Cargo.lock +++ b/src/agent/Cargo.lock @@ -4305,6 +4305,7 @@ checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" name = "test-utils" version = "0.1.0" dependencies = [ - "libc", "nix 0.26.4", ] which results in the following output: $ make -C src/agent check make: Entering directory '/kata-containers/src/agent' standard rust check... cargo fmt -- --check cargo clippy --all-targets --all-features --release --locked \ -- \ -D warnings error: the lock file /kata-containers/src/agent/Cargo.lock needs to be updated but --locked was passed to prevent this If you want to try to generate the lock file without accessing the network, remove the --locked flag and use --offline instead. make: *** [../../utils.mk:184: standard_rust_check] Error 101 make: Leaving directory '/kata-containers/src/agent' Signed-off-by: Aurélien Bombo Signed-off-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- utils.mk | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/utils.mk b/utils.mk index 590184ead142..16e9431fbd9f 100644 --- a/utils.mk +++ b/utils.mk @@ -181,16 +181,9 @@ CWD := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) standard_rust_check: @echo "standard rust check..." cargo fmt -- --check - cargo clippy --all-targets --all-features --release \ + cargo clippy --all-targets --all-features --release --locked \ -- \ -D warnings - cargo check - @DIFF=$$(git diff HEAD); \ - if [ -n "$$DIFF" ]; then \ - echo "ERROR: cargo check resulted in uncommited changes"; \ - echo "$$DIFF"; \ - exit 1; \ - fi # Install a file (full version). #