Set target path in cargo.toml

i have set cargo_target_dir in the windows Path.
and all my target was there.
but how can i set the path for special project in cargo.toml.

You can't set it in your manifest file (Cargo.toml), but you can add a configuration file (.cargo/config.toml) to your project and specify build.target-dir there:

[build]
target-dir = "your-preferred-target-dir"
2 Likes

thanks very much.
i tried it,and it works.
but target dir cant be seted in cargo.toml,its confusing

1 Like

Well, Cargo differentiates between package configuration (through Cargo.toml) and how you can configure Cargo itself (through the configuration files). If you keep that in mind, I think it makes sense that you override the target directory as part of Cargo's configuration and not part of your package manifest, as this only concerns your local builds on your local machine. Downstream packages that use your package as a dependency, say, don't need to know that you like your target directory to be something else than target when you build your package locally.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.