CARGO-LOCATE-PROJECT(1)

πŸ“¦ version 1.82.0, in ubuntu jammy, ubuntu noble

πŸ’– 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 the Cargo.toml at the root of the workspace, as opposed to the current workspace member. It's giving "zoom out, bestie" πŸ”

🌈 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 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 the term.verbose config value <https://doc.rust-lang.org/cargo/reference/config.html>. obsessed 😭
  • -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>. silence is golden, periodt 🀫
  • --color when β€” 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-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. it's a whole scavenger hunt fr fr πŸ•΅οΈ

πŸ’œ 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. cute lil prefix, honestly ⭐
  • --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. stack 'em, bestie πŸ₯ž
  • -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 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 🫢
  • -Z flag β€” unstable (nightly-only) flags to Cargo. Run cargo -Z help for 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 πŸ“

  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, 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