bacon
bacon copied to clipboard
Bacon should ignore changes to editor temporary or lock files
Some editors create temporary or lock files in the same directory as the file being edited. For example vi/vim will create a file named .FILENAME.swp
when the file is first opened for editing, and emacs will create a link named .#FILENAME
when a file open for editing has unsaved changes. When these files are created, they trigger an unnecessary extra run of the current job.
See https://github.com/watchexec/watchexec/blob/35e39afb95d5c66b41f843ce8850ee8da37a5516/src/cli.rs#L265 for a good starting point on which file patterns can be safely ignored. Obviously the *.py?
patterns don't apply here.
OK. Note that if you're willing to make a tested PR, it could be welcome.
Hmm, this is tricky in two ways:
- Technically you can include any file with
include_bytes!
, even temporary or generated files - Use a whitelist of patterns is too coarse, because it will rebuild even if it doesn't need to for files that aren't in the module hierarchy
I think the ideal solution would be to use --emit=dep-info
to tell exactly what files need to be watched. This file is in make syntax so it's annoying to parse, but there's a function in cargo you could copy-paste: https://github.com/rust-lang/cargo/blob/c524fa4e36b1b6134bf6d1fc17f0648f194118c7/src/cargo/core/compiler/fingerprint.rs#L1974
An alternative, at least for git users, would be to leverage the ignore list.
Similar issue here while using insta
: https://github.com/mitsuhiko/insta
Failing tests create temporary snapshots with a .new
extension for review.
So when running bacon test
, if it fails it creates a new file, which triggers the watch, which loops forever and makes everything buggy.
I'm preparing a PR avoiding launching jobs when the modified files are excluded by gitignore rules: https://github.com/Canop/bacon/pull/98
Can you test it and tell me how well it works for you ?
Compiled and tried it and it works properly. As the temp files are called .new
it was indeed the right workflow. Thanks for the help and the quick addition!
released in 2.3.0
Woops! This broke my use case where I literate-compile markdown files into rust, the markdown files are checked-in, but I .gitignore built files such as src/
and Cargo.toml
Bacon now doesn't see changes to my src/
files.
Is there an override? I acknowledge I might be the only one using bacon like this XD
bacon -p src/
does not override the gitignore behaviour
Aha @Canop thought of everything, there's a way to ignore it with job.apply_gitignore
testing now, thank you
apply_gitignore = false
in bacon.toml did the trick, thank you!
Full example if anyone sees this:
[jobs.clippy]
command = ["cargo", "clippy", "--color", "always", "--", "-W", "clippy::pedantic"]
need_stdout = false
apply_gitignore = false