LinuxCommandLibrary

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

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

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 project root. The -C option (nightly) allows changing working directory before searching.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community