Is it possible to deactivate file locking in cargo?

前提是你 提交于 2020-01-11 09:05:32

问题


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:

  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
    


来源:https://stackoverflow.com/questions/38640858/is-it-possible-to-deactivate-file-locking-in-cargo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!