CARGO-LOCATE-PROJECT(1)
π CARGO-LOCATE-PROJECT π
okay bestie so this page is cargo-locate-project, and it's living its best life in the General Commands Manual section, iykyk β¨
πΈ NAME πΈ
cargo-locate-project β prints a JSON representation of where a Cargo.toml file is at π
π¦ SYNOPSIS π¦
cargo locate-project [options]
β¨ DESCRIPTION β¨
So the whole vibe here? This command prints a JSON object to stdout with the full path to the manifest. And how does it find the manifest, you ask? It searches upward for a file named Cargo.toml, starting from the current working directory. Like it's climbing the directory tree looking for its home π
Now here's the tea: if your project happens to be part of a workspace, you get the manifest of the project, not the workspace root. That's the default, no cap. You can override that with the --workspace flag though. And the root workspace gets found by traversing further upward, or by using the field package.workspace after locating the manifest of a workspace member. Main character energy, honestly π
π OPTIONS π
--workspaceβ locates theCargo.tomlat the root of the workspace, as opposed to the current workspace member. It's giving "zoom out, bestie" π
π 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 keyroot.plain: just the path. no frills, no extras, just path π«Ά
-v,--verboseβ use verbose output. And the way that 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>. obsessed π-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>. silence is golden, periodt π€«--colorwhen β controls when colored output is used. Valid values:auto(default): automatically detect if color support is available on the terminal.always: always display colors. πnever: never display colors.
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. it's a whole scavenger hunt fr fr π΅οΈ
π Common Options π
+toolchainβ if Cargo has been installed with rustup, and the first argument tocargobegins 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. cute lil prefix, honestly β--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. stack 'em, bestie π₯-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 next part is important so pay attention π 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>).
-h,--helpβ prints help information. the classic π«Ά-Zflag β unstable (nightly-only) flags to Cargo. Runcargo -Z helpfor details. it's giving forbidden knowledge π
π§ ENVIRONMENT π§
See the reference <https://doc.rust-lang.org/cargo/reference/environment-variables.html> for details on environment variables that Cargo reads. go read it, it's a good time, I promise π
π₯ 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, signed off as CARGO-LOCATE-PROJECT(1) β it's part of the Cargo manual set, and this lil page is dated to match the rest of the docs. go locate some projects, you got this π πβ¨
π¦ where this page comes from
- ubuntu jammy: cargo-1.78 1.78.0+dfsg1ubuntu1~bpo0-0ubuntu0.22.04.1 Β· Apache-2.0 WITH LLVM exception
- ubuntu noble: cargo-1.78 1.78.0+dfsg1ubuntu1-0ubuntu0.24.04.2 Β· 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