I put this in my Cargo.toml
[build]
target-dir = "../my-target"
However, Cargo doesn't recognize this 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)
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 stores the output of a build into the "target" directory. By default, this is the directory named target in the root of your workspace. To change the location, you can set the CARGO_TARGET_DIR environment variable, the build. target-dir config value, or the --target-dir command-line flag.
Windows: %USERPROFILE%\. cargo\config. toml.
All binaries installed with cargo install are stored in the installation root's bin folder. If you installed Rust using rustup.rs and don't have any custom configurations, this directory will be $HOME/. cargo/bin. Ensure that directory is in your $PATH to be able to run programs you've installed with cargo install .
cargo new. The cargo new command allows you to create a new cargo package in the specified directory. Example usage of the command is as shown: $ cargo new [options] path. The command creates a new cargo package with the specified name in the current working directory.
[build]
is a Cargo-level configuration rather than for the project:
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.
Put your [build]
inside $PROJECT_DIR/.cargo/config
or even $HOME/.cargo/config
. See the above link for all the options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With