CARGO-LOCATE-PROJECT(1)

๐Ÿ“ฆ version 1.91.1, in ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute

๐Ÿ’– 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 the Cargo.toml at the root of the workspace, as opposed to the current workspace member. switching from "me" to "the whole fam". ๐Ÿ‘‘

๐ŸŒธ Display Options ๐ŸŒธ

  • --message-format fmt โ€” 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 the term.verbose config value <https://doc.rust-lang.org/cargo/reference/config.html>. ๐Ÿ“ข
  • -q, --quiet โ€” do not print cargo log messages. may also be specified with the term.quiet config value <https://doc.rust-lang.org/cargo/reference/config.html>. shhhh ๐Ÿคซ
  • --color when โ€” 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-path path โ€” path to the Cargo.toml file. by default, Cargo searches for the Cargo.toml file 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 +stable or +nightly). see the rustup documentation <https://rust-lang.github.io/rustup/overrides.html> for more information about how toolchain overrides work. ๐Ÿ‘‘
  • --config KEY=VALUE or PATH โ€” overrides a Cargo configuration value. the argument should be in TOML syntax of KEY=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. ๐ŸŽ€
  • -C PATH โ€” 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 example cargo -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. ๐Ÿซถ
  • -Z flag โ€” unstable (nightly-only) flags to Cargo. run cargo -Z help for 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 โญ

  1. 0: Cargo succeeded. slay! ๐ŸŽ‰
  2. 101: Cargo failed to complete. ๐Ÿ˜ญ

๐Ÿ”ฅ EXAMPLES ๐Ÿ”ฅ

  1. display the path to the manifest based on the current directory:
cargo locate-project

๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘

cargo(1), cargo-metadata(1)


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