sqlx-cli and cargo-watch
sqlx prepare is firing chmod events making it impossible to use with cargo-watch,
files with queries are not necessarily affected, only lib.rs and anything inside bin,
I've tried a few file structures but could still be a coincidence.
Paths updated: [
PathOp { path: "[...]src/lib.rs", op: Some(CHMOD), cookie: None },
PathOp { path: "[...]src/bin/serve.rs", op: Some(CHMOD), cookie: None },
PathOp { path: "[...]src/bin/export.rs", op: Some(CHMOD), cookie: None }
]
Minimal Reproduction
- install cargo-watch and sqlx-cli
- run
cargo watch --why -x 'sqlx prepare'
Info
- SQLx cli version: 0.7.3
- Operating system: linux
-
rustc --version: 1.72.0-nightly
I am also seeing this issue with watchexec.
any news? need a way to combine both
why even --check triggers file changes
The first problem is reliably getting the compiler to run. If you run cargo check but no project files have changed, Cargo won't do anything. Of course, we need the macros to run to generate updated metadata (which is needed even when running --check).
The second problem is getting Cargo to only recompile what's absolutely necessary. Our original strategy was to run cargo clean sqlx to invalidate any crates that depend on it, but that caused sqlx itself to recompile, as well as any crates in the graph that depend on it but don't actually use the proc macros.
Then we had an issue cargo cleaning workspace crates because it'd wipe all incremental compilation artifacts.
So instead we just touch project files to update the mtime which causes an incremental recompile of the crate.
There's lots of other alternatives we've tried but weren't happy with. All you have to do is look through the history of the following file to see everything we've tried: https://github.com/launchbadge/sqlx/blob/main/sqlx-cli/src/prepare.rs
I'm happy to discuss any improvements over the status quo.