我把它放在我的 Cargo.toml 中
[build]
target-dir = "../my-target"
但是,Cargo 无法识别此 key 。
cargo run --release --bin my_project
warning: unused manifest key: build
error: failed to open: /.../project-root/target/releases/.cargo-lock
Caused by:
Permission denied (os error 13)
带有环境变量的自定义目标目录有效:
CARGO_TARGET_DIR=../my-target cargo run --bin my_project
但是我如何在 Cargo.toml 中指定 '../my-target'?
最佳答案
[build]
是一个 Cargo-level configuration而不是为了项目:
This document will explain how Cargo’s configuration system works, as well as available keys or configuration. For configuration of a project through its manifest, see the manifest format.
将您的 [build]
放入 $PROJECT_DIR/.cargo/config
甚至 $HOME/.cargo/config
中。有关所有选项,请参阅上面的链接。
关于rust - 如何指定自定义 Cargo 输出目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50364390/