cargo-watch icon indicating copy to clipboard operation
cargo-watch copied to clipboard

How to exclude folders?

Open theronic opened this issue 6 years ago • 9 comments

How do I instruct cargo watch to exclude folders? Doesn't seem to be supported so far, by the looks of cargo watch --help | grep exclude.

theronic avatar Nov 27 '18 07:11 theronic

cargo watch --ignore 'folder/*' works for me.

You could also add /folder to your .gitignore to always exclude it in future invocations.

hcpl avatar Nov 27 '18 07:11 hcpl

Thanks. In this particular case, I have a mixed-source project (ClojureScript & Rust) and I didn't want Cargo to restart when I touch my *.cljs files :)

theronic avatar Nov 27 '18 13:11 theronic

/folder in .gitignore doesn't work.

skull-squadron avatar Aug 13 '19 04:08 skull-squadron

I came here for this as well. I'd use an .ignore file for the projects, where you want to version-control none source-code related things as well.

CGMossa avatar Nov 20 '21 23:11 CGMossa

This will be properly supported with the new (experimental) filtering engine when it lands later this year:

$ env CARGO_WATCH_FILTERER=tagged cargo watch

I'll reclose when that arrives

passcod avatar Nov 21 '21 00:11 passcod

Correction, this will be properly supported via .gitignore and .ignore in the default/normal mode for a future release which will include Watchexec 2.

passcod avatar Jan 19 '22 01:01 passcod

Just my 2 pence: I want to ignore some folders which are checked into git. In my case, I have sass files which I want to version control but I don't want to restart the server every time I edit them - is that possible?

Thanks!

yatesco avatar Jan 06 '23 11:01 yatesco

@yatesco that is supported, with --ignore '**/foldername/**. This issue is for the /foldername syntax from gitignore.

passcod avatar Jan 06 '23 12:01 passcod

Thanks @passcod. For my situation cargo watch -w src -x run is actually the simplest as the other folders are siblings of src. Thanks :-)

yatesco avatar Jan 06 '23 14:01 yatesco