Skip to content

Project using tonic-prost-build rebuilding when unrelated files not in .gitignore change #2415

@WolleTD

Description

@WolleTD

Bug Report

Version

  • tonic-prost-build 0.14.x / 969408e
  • Rust 1.89.0, Rust 1.90.0

Platform

Linux wolfgnu 6.16.8-arch3-1 #1 SMP PREEMPT_DYNAMIC Mon, 22 Sep 2025 22:08:35 +0000 x86_64 GNU/Linux

Description

When using tonic-prost-build (any version, since it didn't exist before 0.14) in a build.rs, the project is
rebuilt whenever a file in the project directory changes, even if it isn't part of the build.
Adding the file to .gitignore fixes that. target/ isn't affected even when not in .gitignore.

I narrowed this issue down to commit 969408e. Unfortunately, that's a pretty large one introducing the tonic-prost-build crate for the first time.

I managed to create a minimal example. Create a project with these files (patch):

# Cargo.toml
[package]
name = "test-prost"
version = "0.1.0"
edition = "2024"

[dependencies]

[build-dependencies]
#tonic-prost-build = { path = "../tonic/tonic-prost-build" }
#tonic-build = { git = "https://github.com/hyperium/tonic.git", rev = "761ebf5f" }
tonic-prost-build = "0.14.2"
// build.rs
fn main() {
    tonic_prost_build::compile_protos("src/test.proto").unwrap();
    //tonic_build::compile_protos("src/test.proto").unwrap();
}
// src/main.rs
fn main() {
    println!("Hello, world!");
}
// src/test.proto
syntax = "proto3";
message Null {}
service Test {
  rpc Test(Null) returns (Null) {}
}
  1. Run cargo build once
  2. Do nothing an run cargo build again: no build happens
  3. touch foo.txt and run cargo build: project is rebuilding
  4. Repeat 2 and 3 until sufficiently convinced
  5. Add foo.txt to .gitignore
  6. Run cargo build: project is rebuilding because .gitignore changed
  7. touch foo.txt and run cargo build: no build happens

The issue does not appear with tonic-build from 761ebf5, which is already using prost 0.14.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions