当“cargo install"由于系统配置问题而失败时,如何避免重建依赖项? [英] How can I avoid rebuilding dependencies when `cargo install` fails due to a system configuration issue?
问题描述
我正在尝试 cargo install
一个具有许多依赖项的项目.由于某些系统配置问题,后来的依赖项之一无法构建:
I'm trying to cargo install
a project with many dependencies. One of the later dependencies fails to build due to some system configuration issue:
cargo install diesel_cli
... many dependencies here...
Compiling diesel_cli v1.4.1
error: linking with `cc` failed: exit code: 1
|
= note: ...large output removed...
= note: ld: library not found for -lmysqlclient
clang: error: linker command failed with exit code 1 (use -v to see invocation)
一旦我认为我已经解决了系统配置问题,我需要重新运行cargo install
,等待第一组依赖项构建,然后看看我是否通过了失败.
Once I think I've solved the system configuration issue, I need to re-run cargo install
, wait a while for the first set of dependencies to build, then see if I get past the failure.
如何避免重建所有这些依赖项?
How can I avoid rebuilding all of those dependencies?
推荐答案
错误消息包含包含失败构建工件的目录:
The error message contains the directory containing the failed build artifacts:
error: failed to compile `diesel_cli v1.4.1`, intermediate artifacts can be found at `/var/folders/_b/d4_bd15x7s5g99cjvyhpw26w0000gp/T/cargo-installDQOdPD`
您可以通过 --target-dir
选项(或设置 CARGO_TARGET_DIR
环境变量)传递该目录以再次使用它,避免重建依赖项:>
You can pass that directory via the --target-dir
option (or setting the CARGO_TARGET_DIR
environment variable) to use it again, avoiding rebuilding the dependencies:
cargo install diesel_cli --target-dir=/var/folders/_b/d4_bd15x7s5g99cjvyhpw26w0000gp/T/cargo-installDQOdPD
这篇关于当“cargo install"由于系统配置问题而失败时,如何避免重建依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!