grpc / grpc/grpc-rust

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

Open
#2,415 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
12.5k
Forks
1.3k
Avg merge
4d 7h
Merged PRs (30d)
24

Description

## 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](https://gist.github.com/WolleTD/e01a426f5c2fbc89fde3d34e58206e82)):
```toml
# 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"
```
```rust
// build.rs
fn main() {
tonic_prost_build::compile_protos("src/test.proto").unwrap();
//tonic_build::compile_protos("src/test.proto").unwrap();
}
```
```rust
// src/main.rs
fn main() {
println!("Hello, world!");
}
```
```protobuf
// 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 761ebf5f, which is already using `prost 0.14`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.