CARGO-PKGID(1)
π CARGO-PKGID β the manual page, but make it cute π
okay bestie, welcome to the cargo-pkgid page from the General Commands Manual, i'm your host and i'm obsessed with this command actually.
β¨ NAME β¨
cargo-pkgid β print a fully qualified package specification. that's it. that's the job. she's simple, she's precise, she eats π
π¦ SYNOPSIS π¦
cargo pkgid [options] [spec]
πΈ DESCRIPTION πΈ
so here's the vibe: you hand her a spec argument, and she prints out the fully qualified package ID specifier for a package or a dependency in the current workspace. literally just the full glow-up version of whatever you pointed at.
β οΈ heads up: if spec is ambiguous about which package it refers to in the dependency graph, this command will throw an error. no guessing, no coin flips, she will simply not do it.
and if you give her no spec at all? she prints the specifier for the local package. lowkey the default behavior is giving main character π«Ά
also this command requires that a lockfile is available and that dependencies have been fetched. no lockfile, no crumbs, no service π
a package specifier is made of a name, a version, and a source URL. you're allowed to use partial specifiers to succinctly match a specific package β as long as it matches only one package. one. singular. don't be greedy π
and this same specifier format is used by other parts in Cargo too, like cargo-metadata(1) and the JSON messages emitted by Cargo (https://doc.rust-lang.org/cargo/reference/external-tools.html#json-messages). it's iconic across the whole ecosystem, iykyk.
the format of a spec can be one of these:
nameβ for examplebitflagsname@versionβ for examplebitflags@1.0.4urlβ for examplehttps://github.com/rust-lang/cargourl#versionβ for examplehttps://github.com/rust-lang/cargo#0.33.0url#nameβ for examplehttps://github.com/rust-lang/crates.io-index#bitflagsurl#name@versionβ for examplehttps://github.com/rust-lang/cargo#crates-io@0.21.0
the full specification grammar lives in chapter Package ID Specifications (https://doc.rust-lang.org/cargo/reference/pkgid-spec.html) if you wanna go read the source material bestie π
π OPTIONS π
Package Selection
-pspec,--packagespec β get the package ID for the given package instead of the current package. like, "not this one, that one" energy.
Display Options
-v,--verboseβ use verbose output. may be specified twice for "very verbose" output, which includes extra output such as dependency warnings and build script output. may also be specified with theterm.verboseconfig value (https://doc.rust-lang.org/cargo/reference/config.html). double it and it gets louder, periodt.-q,--quietβ do not print cargo log messages. may also be specified with theterm.quietconfig value (https://doc.rust-lang.org/cargo/reference/config.html). silence is golden, she said it first π--colorwhen β 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 forever π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-pathpath β path to theCargo.tomlfile. by default, Cargo searches for theCargo.tomlfile in the current directory or any parent directory. she will climb the whole family tree to find it fr fr π³--lockedβ asserts that the exact same dependencies and versions are used as when the existingCargo.lockfile was originally generated. Cargo will exit with an error when either of the following scenarios arises:- the lock file is missing.
- Cargo attempted to change the lock file due to a different dependency resolution.
it may be used in environments where deterministic builds are desired, such as in CI pipelines. if you're a CI girlie, this one's for you π
--offlineβ prevents Cargo from accessing the network for any reason. without this flag, Cargo will stop with an error if it needs to access the network and the network is not available. with this flag, Cargo will attempt to proceed without the network if possible.
π beware bestie: this may result in different dependency resolution than online mode. Cargo will restrict itself to crates that are downloaded locally, even if there might be a newer version as indicated in the local copy of the index. see the cargo-fetch(1) command to download dependencies before going offline. do your homework before you go offline, not during.
may also be specified with the net.offline config value (https://doc.rust-lang.org/cargo/reference/config.html).
--frozenβ equivalent to specifying both--lockedand--offline. two-for-one, a bundle deal, she's efficient π
Common Options
+toolchainβ if Cargo has been installed with rustup, and the first argument tocargobegins with+, it will be interpreted as a rustup toolchain name (such as+stableor+nightly). see the rustup documentation (https://rust-lang.github.io/rustup/overrides.html) for more information about how toolchain overrides work. pick your fighter β¨--configKEY=VALUE or PATH β overrides a Cargo configuration value. the argument should be in TOML syntax ofKEY=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.-CPATH β 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 examplecargo -C path/to/my-project build. order matters, don't fight it π«
π₯ 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-optionsflag to enable (see #10098https://github.com/rust-lang/cargo/issues/10098). nightly girlies only, sorry to the stable girlies, i don't make the rules.
-h,--helpβ prints help information. when in doubt, ask her directly π-Zflag β unstable (nightly-only) flags to Cargo. runcargo -Z helpfor details.
π ENVIRONMENT π
see the reference (https://doc.rust-lang.org/cargo/reference/environment-variables.html) for details on environment variables that Cargo reads. the full tea is over there, i'm just the messenger π
β EXIT STATUS β
0: Cargo succeeded. π101: Cargo failed to complete. π
π EXAMPLES π
- retrieve package specification for
foopackage:
cargo pkgid foo
- retrieve package specification for version
1.0.0offoo:
cargo pkgid foo@1.0.0
- retrieve package specification for
foofrom crates.io:
cargo pkgid https://github.com/rust-lang/crates.io-index#foo
- retrieve package specification for
foofrom a local package:
cargo pkgid file:///path/to/local/package#foo
π§ SEE ALSO π§
cargo(1), cargo-generate-lockfile(1), cargo-metadata(1), Package ID Specifications (https://doc.rust-lang.org/cargo/reference/pkgid-spec.html), JSON messages (https://doc.rust-lang.org/cargo/reference/external-tools.html#json-messages)
and that's the whole page bestie β this one's from the General Commands Manual, titled CARGO-PKGID(1), and yeah, that little CARGO-PKGID(1) down at the bottom is just her signature. go forth and get those fully qualified specs πβ¨
π¦ where this page comes from
- ubuntu jammy: cargo-1.80 1.80.1+dfsg0ubuntu1~bpo0-0ubuntu0.22.04.1 Β· Apache-2.0 WITH LLVM exception
- ubuntu noble: cargo-1.80 1.80.1+dfsg0ubuntu1-0ubuntu0.24.04.01 Β· MIT OR Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms