← 返回命令列表

Linux command

cargo-pkgid 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Show package ID for current package

cargo pkgid

Show package ID for a dependency

cargo pkgid [serde]

Show package ID for a specific version of a dependency

cargo pkgid [serde@1.0.0]

Show package ID using a specific Cargo.toml

cargo pkgid --manifest-path [path/to/Cargo.toml] [serde]

Show package ID from a URL

cargo pkgid [https://github.com/rust-lang/crates.io-index#serde]

说明

cargo pkgid prints the fully qualified package ID specification for a package in the dependency graph. The output includes the source URL, package name, and version in a canonical format that can be used with other Cargo commands like `cargo update -p`. This command is primarily useful when multiple versions of the same package exist in the dependency tree and disambiguation is needed. It accepts partial specifications such as just the name or name with version, and resolves them against the lockfile. The Cargo.lock file must exist and dependencies must be fetched before this command can be used.

参数

-p, --package _spec_
Package to query
--manifest-path _path_
Path to Cargo.toml
--locked
Assert that the exact same dependencies and versions are used as when the existing Cargo.lock was generated
--offline
Prevent Cargo from accessing the network
--frozen
Equivalent to specifying both --locked and --offline
--color _when_
Control colored output: auto (default), always, or never
-v, --verbose
Verbose output. Specify twice for very verbose output.
-q, --quiet
Do not print cargo log messages

FAQ

What is the cargo-pkgid command used for?

cargo pkgid prints the fully qualified package ID specification for a package in the dependency graph. The output includes the source URL, package name, and version in a canonical format that can be used with other Cargo commands like `cargo update -p`. This command is primarily useful when multiple versions of the same package exist in the dependency tree and disambiguation is needed. It accepts partial specifications such as just the name or name with version, and resolves them against the lockfile. The Cargo.lock file must exist and dependencies must be fetched before this command can be used.

How do I run a basic cargo-pkgid example?

Run `cargo pkgid` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -p, --package _spec_ do in cargo-pkgid?

Package to query