From e79f69563c647cb54a834f9dc160ce2f5be1b5ba Mon Sep 17 00:00:00 2001 From: hobostay <110803307+hobostay@users.noreply.github.com> Date: Thu, 30 Apr 2026 18:12:33 +0000 Subject: [PATCH] fix(build): skip rerun-if-changed for .files() in Buf mode In Buf mode, `.files()` holds proto-relative names (e.g. "my/service.proto"), not filesystem paths. Emitting `cargo:rerun-if-changed` for these points cargo at non-existent files, forcing a rebuild on every invocation. This is the same issue that was fixed for Precompiled mode in #56, but Buf mode was missed in that fix. --- connectrpc-build/src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/connectrpc-build/src/lib.rs b/connectrpc-build/src/lib.rs index b5970be..7cdfc21 100644 --- a/connectrpc-build/src/lib.rs +++ b/connectrpc-build/src/lib.rs @@ -311,7 +311,12 @@ impl Config { DescriptorSource::Precompiled(p) => { println!("cargo:rerun-if-changed={}", p.display()); } - DescriptorSource::Protoc | DescriptorSource::Buf => { + // Both Buf and Precompiled modes use proto-relative names (not + // filesystem paths) in `.files()`. Emitting `rerun-if-changed` + // for those would point cargo at non-existent files and force a + // rebuild every invocation. + DescriptorSource::Buf => {} + DescriptorSource::Protoc => { for f in &self.files { println!("cargo:rerun-if-changed={}", f.display()); }