CARGO-LOCATE-PROJECT(1)
๐ CARGO-LOCATE-PROJECT ๐
okay bestie, welcome to the General Commands Manual glow-up of cargo-locate-project โ the lil command that just tells you where your Cargo.toml is hiding. that's it. that's the whole job. and honestly? iconic. ๐
โจ NAME โจ
cargo-locate-project โ print a JSON representation of a Cargo.toml file's location ๐บ๏ธ๐
๐ SYNOPSIS ๐
cargo locate-project [options]
๐ฆ DESCRIPTION ๐ฆ
so like. this command prints a JSON object to stdout with the full path to the manifest. and how does it find the manifest? it searches upward for a file named Cargo.toml, starting from the current working directory. it's giving detective energy fr fr ๐โจ
and here's the plot twist: if your project happens to be part of a workspace</>, the manifest of the project gets output โ not the workspace root. so you get the member, not the mom. ๐ฉ๐ง
but wait, you can override that with the --workspace flag. and how does it find the root workspace? by traversing further upward, or by using the field package.workspace after locating the manifest of a workspace member. no cap, that's the whole mechanism. ๐ง
๐ OPTIONS ๐
--workspaceโ locate theCargo.tomlat the root of the workspace, as opposed to the current workspace member. switching from "me" to "the whole fam". ๐
๐ธ Display Options ๐ธ
--message-formatfmt โ the representation in which to print the project location. valid values are:json(default): a JSON object with the path under the key "root". ๐plain: just the path. no frills, no decorations, just the raw path bestie. โจ
-v,--verboseโ use verbose output. and you can specify it twice for "very verbose" output, which includes extra output such as dependency warnings and build script output. may also be specified with theterm.verboseconfig value <https://doc.rust-lang.org/cargo/reference/config.html>. ๐ข-q,--quietโ do not print cargo log messages. may also be specified with theterm.quietconfig value <https://doc.rust-lang.org/cargo/reference/config.html>. shhhh ๐คซ--colorwhen โ control when colored output is used. valid values:auto(default): automatically detect if color support is available on the terminal. ๐ฎalways: always display colors. rainbow mode activated ๐never: never display colors. monochrome era ๐ค
may also be specified with the term.color config value <https://doc.rust-lang.org/cargo/reference/config.html>.
๐งธ Manifest Options ๐งธ
--manifest-pathpath โ path to theCargo.tomlfile. by default, Cargo searches for theCargo.tomlfile in the current directory or any parent directory. basically: "here's exactly where to look, don't go snooping". ๐ต๏ธโโ๏ธ
๐ Common Options ๐
+toolchainโ if Cargo has been installed with rustup, and the first argument to cargo begins with+, it will be interpreted as a rustup toolchain name (such as+stableor+nightly). see the rustup documentation <https://rust-lang.github.io/rustup/overrides.html> for more information about how toolchain overrides work. ๐--configKEY=VALUE or PATH โ overrides a Cargo configuration value. the argument should be in TOML syntax ofKEY=VALUE, or provided as a path to an extra configuration file. this flag may be specified multiple times</>. see the command-line overrides section <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides> for more information. ๐-CPATH โ changes the current working directory before executing any specified operations. this affects things like where cargo looks by default for the project manifest (Cargo.toml), as well as the directories searched for discovering.cargo/config.toml, for example. this option must appear before the command name, for examplecargo -C path/to/my-project build.
๐จ okay this one matters: this option is only available on the nightly channel <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and requires the -Z unstable-options flag to enable (see #10098 <https://github.com/rust-lang/cargo/issues/10098>). so no, it will not just work on stable, bestie. it's giving exclusive. ๐
-h,--helpโ prints help information. the classic. the goat. ๐ซถ-Zflag โ unstable (nightly-only) flags to Cargo. runcargo -Z helpfor details. โญ
๐ ENVIRONMENT ๐
see the reference <https://doc.rust-lang.org/cargo/reference/environment-variables.html> for details on environment variables that Cargo reads. ๐ฑ
โญ EXIT STATUS โญ
0: Cargo succeeded. slay! ๐101: Cargo failed to complete. ๐ญ
๐ฅ EXAMPLES ๐ฅ
- display the path to the manifest based on the current directory:
cargo locate-project
๐ SEE ALSO ๐
and that's the whole page bestie, you ate it up ๐ this was the CARGO-LOCATE-PROJECT(1) page from the General Commands Manual, so go forth and locate those projects. periodt. ๐ฆโจ๐
๐ฆ where this page comes from
- ubuntu jammy: cargo-1.91 1.91.1+dfsg~22.04-0ubuntu0.22.04.3 ยท Apache-2.0 WITH LLVM exception
- ubuntu noble: cargo-1.91 1.91.1+dfsg~24.04-0ubuntu0.24.04.2 ยท Apache-2.0 WITH LLVM exception
- ubuntu noble: cargo-1.91 1.91.1+dfsg~24.04-0ubuntu0.24.04.3 ยท Apache-2.0 WITH LLVM exception
- ubuntu questing: cargo-1.91 1.91.1+dfsg-0ubuntu3~25.10.1
- ubuntu resolute: cargo-1.91 1.91.1+dfsg-0ubuntu3 ยท MIT OR Apache-2.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms