cargo watch
triggering on file that hasn't changed (only read) #193
Description
Hi! Thank you for a great tool :-)
I'm currently experiencing cargo watch -x test
looping indefinitely, with --why
reporting that the cause is a file that hasn't been modified (the file is read during cargo test
and copied to a temp dir, but the original isn't modified itself).
I was wondering if you might have some insight?
Steps to reproduce:
git clone https://github.com/Malax/libcnb.rs
(currently atfd1686f8d0fe07aca5e0b9592fbdee1919591fdb
)cd libcnb.rs/examples/example-02-ruby-sample/
cargo watch -x test --why
Expected:
Test command is run only once, and waits for next modification to the project source before being re-run.
Actual:
Test command is run repeatedly in a loop.
Output says:
2022-02-02T23:27:19.085+00:00 - INFO - Paths updated: [PathOp { path: "/Users/emorley/src/libcnb.rs/examples/example-02-ruby-sample/test-fixtures/simple-ruby-app/app.rb", op: Some((empty)), cookie: None }, PathOp { path: "/Users/emorley/src/libcnb.rs/examples/example-02-ruby-sample/test-fixtures/simple-ruby-app/Gemfile", op: Some((empty)), cookie: None }, PathOp { path: "/Users/emorley/src/libcnb.rs/examples/example-02-ruby-sample/test-fixtures/simple-ruby-app/Gemfile.lock", op: Some((empty)), cookie: None }]
Stating the files before/after shows nothing has changed:
$ stat test-fixtures/simple-ruby-app/app.rb File: test-fixtures/simple-ruby-app/app.rb
Size: 150 Blocks: 8 IO Block: 4096 regular file
Device: 1,8 Inode: 112878460 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 503/ emorley) Gid: ( 20/ staff)
Access: 2022-02-02 14:49:13.822279666 +0000
Modify: 2022-02-02 14:49:13.762440366 +0000
Change: 2022-02-02 14:49:13.762440366 +0000
Birth: 2022-02-02 14:49:13.760673662 +0000
$ cargo watch -x test --why
...
<Ctrl+C>
$ stat test-fixtures/simple-ruby-app/app.rb File: test-fixtures/simple-ruby-app/app.rb
Size: 150 Blocks: 8 IO Block: 4096 regular file
Device: 1,8 Inode: 112878460 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 503/ emorley) Gid: ( 20/ staff)
Access: 2022-02-02 14:49:13.822279666 +0000
Modify: 2022-02-02 14:49:13.762440366 +0000
Change: 2022-02-02 14:49:13.762440366 +0000
Birth: 2022-02-02 14:49:13.760673662 +0000
During the test setup, the files in question are copied to a temporary directory here using fs_extra::dir::copy()
:
https://github.com/Malax/libcnb.rs/blob/fd1686f8d0fe07aca5e0b9592fbdee1919591fdb/libcnb-test/src/app.rs#L5-L21
...but the target directory is in TMP and so not watched, and the source file was never modified.
Additional information
Cargo watch was installed using cargo install cargo-watch
(I reinstalled just now using --force
to ensure it was recently compiled, given not using --locked
).
Versions:
$ rustc --version
rustc 1.59.0-beta.5 (28c8a34e1 2022-01-27)
$ cargo watch --version
cargo-watch 8.1.1
(though this also repros on Rust stable)
This is on macOS 12.2.