[英]How can I specify a custom Cargo output directory?
I put this in my Cargo.toml我把它放在我的 Cargo.toml 中
[build]
target-dir = "../my-target"
However, Cargo doesn't recognize this key.但是,Cargo 无法识别此键。
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)
The custom target dir with the environment variable works:带有环境变量的自定义目标目录有效:
CARGO_TARGET_DIR=../my-target cargo run --bin my_project
but how can I specify '../my-target' in Cargo.toml?但是如何在 Cargo.toml 中指定“../my-target”?
[build]
is a Cargo-level configuration rather than for the project: [build]
是Cargo 级别的配置,而不是针对项目:
This document will explain how Cargo's configuration system works, as well as available keys or configuration.
本文档将解释 Cargo 的配置系统如何工作,以及可用的密钥或配置。 For configuration of a project through its manifest, see the manifest format.
有关通过其清单配置项目的信息,请参阅清单格式。
Put your [build]
inside $PROJECT_DIR/.cargo/config
or even $HOME/.cargo/config
.将您的
[build]
放在$PROJECT_DIR/.cargo/config
甚至$HOME/.cargo/config
。 See the above link for all the options.有关所有选项,请参阅上面的链接。
Use the CARGO_TARGET_DIR
environment variable :使用
CARGO_TARGET_DIR
环境变量:
CARGO_TARGET_DIR=../my-target cargo run --bin my_project
(This is stated in the question, but I wanted to highlight it for anyone that skips over that) (这是在问题中说明的,但我想为跳过它的任何人强调它)
CARGO_TARGET_DIR=../my-target cargo run --bin my_projectCARGO_TARGET_DIR=../my-target cargo run --bin my_projectCARGO_TARGET_DIR=../my-target cargo run --bin my_projectCARGO_TARGET_DIR=../my-target cargo run --bin my_projectCARGO_TARGET_DIR=../my-target cargo run --bin my_projectCARGO_TARGET_DIR=../my-target cargo run --bin my_projectvvcvvvCARGO_TARGET_DIR=../my-target cargo run --bin my_projectv637u3./337eyh8uew0iu722.ls-4 82[dh3lfh3f.d;epe] pd;wegoj48t732sdl3od';e3;4lpw04u8uer43w4lp4pli0peodkhp5;r/b?/; CARGO_TARGET_DIR=../my-target货物运行 --bin my_projectCARGO_TARGET_DIR=../my-target货物运行 --bin my_projectCARGO_TARGET_DIR=../my-target货物运行 --bin my_projectCARGO_TARGET_DIR=../my-target货物运行- -bin my_projectCARGO_TARGET_DIR=../my-target货物运行--bin my_projectCARGO_TARGET_DIR=../my-target货物运行--bin my_projectvvcvvvCARGO_TARGET_DIR=../my-target货物运行--bin my_projectv637u3./337eyh72282iu4 [dh3lfh3f.d;epe] pd;wegoj48t732sdl3od';e3;4lpw04u8uer43w4lp4pli0peodkhp5;r/b?/; ;;phlli;yog;jhjou[uj[jud7ffe5e6e6wuduy373y82889478
;;phlli;yog;jhjou[uj[jud7ffe5e6e6wuduy373y82889478
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.