Overview
If the current user does not own every file in the current repository, such as artifacts owned by a docker container, cargo watch errors out even if the directory in question is explicitly ignored.
See this repo for reproduction code. Readme of that repo copied below:
Reproduction
Clone the repo linked above. Then, run the following commands:
cargo binstall cargo-watch
docker compose up -d mongodb
cargo watch -- cargo run or just cargo watch
Expected behavior
cargo watch should know to ignore the ignored artifacts, per the documentation in cargo watch --help, which states:
By default, the workspace directories of your project and all local dependencies are watched, except for the target/ and .git/ folders. Your .ignore and .gitignore files are used to filter paths.
Actual behavior
Observe the error: Error: I/O error: Permission denied (os error 13), despite .gitignore ignoring that directory.
Notes
Tested with cargo-watch 8.5.2
Notes
While an argument can be made that users must go through extra steps to ensure that e.g. container artifacts are owned by the current user, and not by the container's root, some users may want to leave behavior default, and regardless cargo watch behavior ought to align with its documented claim