How can I get cargo to recompile changed files automatically?

cargo watch

In case you are working on a server project (e.g. hyper, iron, etc) that keeps running and you need it to be restarted when files change, you can use cargo watch. Install:

cargo install cargo-watch

And then run:

cargo watch -x run

And to watch changes in only the src folder and clear the console use:

cargo watch -c -w src -x run

See the cargo-watch README for more examples.

watchexec

Alternatively, you can use watchexec. Install it:

cargo install watchexec-cli

And then use it like this:

watchexec -r cargo run

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)