问题
I want to run the following commands side by side
cargo watch "check"
cargo watch "build"
I want to run cargo watch build
in the background and use cargo watch check
to look at the error messages.
The problem is that cargo watch check
always runs after cargo watch build
and then also needs to wait on the file lock
cargo check
Blocking waiting for file lock on build directory
I don't think that a file lock would be required for cargo check. Is it possible to disable file locking in cargo?
回答1:
I don't think that a file lock would be required for cargo check.
I can think of in one reason: build scripts. A build script can generate files that are included in the crate, checking the crate without generating the files would probably produce errors. Running 2 instances of a build script in parallel is not a good idea (conflicting file writes, etc), so the locking is required.
I want to run the following commands side by side
You have two options:
Sequential: install cargo-do and run
cargo watch "do check, build"
this will first run cargo check
and then cargo build
(if cargo check
did not find an error).
Parallel: change the target-dir for one of the two cargo commands:
CARGO_TARGET_DIR=/tmp cargo watch check
来源:https://stackoverflow.com/questions/38640858/is-it-possible-to-deactivate-file-locking-in-cargo