LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

cargo-locate-project

Print the path to a project's Cargo.toml

TLDR

Show manifest path
$ cargo locate-project
copy
Show workspace root manifest
$ cargo locate-project --workspace
copy
Output as plain path
$ cargo locate-project --message-format plain
copy
Output as JSON
$ cargo locate-project --message-format json
copy
Locate project from a specific directory
$ cargo locate-project --manifest-path [path/to/Cargo.toml]
copy

SYNOPSIS

cargo locate-project [options]

DESCRIPTION

cargo locate-project prints the path to the Cargo.toml manifest file for the current package. Searches current directory and parent directories for the manifest.

PARAMETERS

--workspace

Locate workspace root Cargo.toml instead of current package
--message-format format
Output format: json (default), plain
--manifest-path path
Path to Cargo.toml
-v, --verbose
Verbose output
-q, --quiet
Suppress log messages
--color WHEN
Control color output: auto, always, never

OUTPUT

JSON format (default)

$ {"root":"/path/to/project/Cargo.toml"}
copy
Plain format
$ /path/to/project/Cargo.toml
copy

EXIT STATUS

0

Success
101
Failed to locate manifest

CAVEATS

Useful for scripts and tooling that need to find the project root. Returns exit code 101 if no Cargo.toml is found in the current or any parent directory.

SEE ALSO

Copied to clipboard
Kai