Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to deactivate file locking in cargo?

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?

like image 597
Maik Klein Avatar asked Jul 28 '16 15:07

Maik Klein


1 Answers

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:

  1. 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).

  1. Parallel: change the target-dir for one of the two cargo commands:

    CARGO_TARGET_DIR=/tmp cargo watch check
    
like image 101
malbarbo Avatar answered Sep 29 '22 13:09

malbarbo