talira

cargo-watch

Watches over your Cargo project's source

open sourceCC0-1.0self-hostablefreearchived

cargo-watch's makers archived or ended it on 18 Jan 2025.

Its maintainer archived the repository in January 2025: it 'will not receive further updates, but does remain available', and he recommends Bacon or Watchexec instead.

cargo-watch watches a Rust project's source and runs Cargo commands when it changes: cargo check by default, or test, clippy, run and any shell command, restarting a command that's still running. It honours .gitignore and .ignore, watches the crate's local path dependencies too, and passes --features to every Cargo command. It's built on the watchexec library by the same maintainer. He archived it in January 2025 and recommends bacon or watchexec instead: version 8.5.3 still installs and works, but it gets no more updates.

Problems it solves

  • re-run cargo check every time I save a Rust file
  • run my Rust tests automatically whenever the source changes
  • restart cargo run on my Rust web server when I edit the code
  • rebuild when a path dependency in my Cargo workspace changes, not just the current crate
  • clear the terminal before each cargo build so I only see the latest errors
  • is cargo watch still maintained, and what should I use instead

Features

  • runs cargo check by default; -x runs other Cargo commands, -s shell commands
  • restarts a running command on change (--no-restart to let it finish)
  • honours .gitignore and .ignore files, and ignores target/ and .git/
  • watches local path dependencies of the crate
  • --features passed to every Cargo command
  • --clear, --postpone, --poll, --delay debounce and --why to show changed paths
  • desktop notification on change (experimental)
  • prebuilt binaries, .deb and .rpm packages

Limitations

  • Doesn't work outside a Cargo project: its README points to watchexec for anything else1
  • Doesn't restart an app only after a build succeeds: its README leaves supervising long-running processes to a process manager such as systemd-run or pm21
  • Doesn't support Windows 7 or older1

Capabilities

Has a command line toolplan not known

Alternatives

The same job

These do what cargo-watch does.

  1. bacon Background code checker
  2. entr Run arbitrary commands when files change
  3. watchexec Executes commands in response to file modifications

Compare cargo-watch with the top 3