Redirect build artifacts without editing config files.
Section: Cargo config
Set target dir by environment variable
bash
bash
CARGO_TARGET_DIR=target-ci cargo buildExplanation
Useful in CI, benchmarking, or separate debug and release workflows.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Cargo config
Create project-local Cargo config
Store configuration in the project under `.cargo/config.toml`.
Override config on one command
Pass a config key or file path at runtime.