CARGO-PKGID(1)
β¨ cargo-pkgid β¨
okay bestie, welcome to cargo-pkgid, section 1 of the General Commands Manual π this is the little cutie that prints out a fully qualified package specification for you. she's giving main character energy in your terminal and honestly? obsessed.
πΈ NAME πΈ
cargo-pkgid β print a fully qualified package specification π
π¦ 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 dependency chillin' in the current workspace. periodt. π
but like, heads up β if spec is ambiguous about which package it's referring to in the dependency graph, she will throw an error. no guessing games, she's not about that life. π
and if you give her no spec at all? she just prints the specifier for the local package. simple. iconic. π
real talk though: this command requires that a lockfile is available and that dependencies have been fetched. no lockfile, no service. π
A package specifier is made of three things: a name, a version, and a source URL. you're allowed to use partial specifiers to match a specific package super succinctly β as long as it matches only one package. slay π
The format of a spec can be one of these babes:
nameβ e.g.bitflagsname@versionβ e.g.bitflags@1.0.4urlβ e.g.https://github.com/rust-lang/cargourl#versionβ e.g.https://github.com/rust-lang/cargo#0.33.0url#nameβ e.g.https://github.com/rust-lang/crates.io-index#bitflagsurl#name@versionβ e.g.https://github.com/rust-lang/cargo#crates-io@0.21.0
π OPTIONS π
π Package Selection
-pspec,--packagespec β grab the package ID for the given package instead of the current package. like, "not you, her." π«Ά
π Display Options
-v,--verboseβ use verbose output. can be specified twice for "very verbose" output, which includes extra output like dependency warnings and build script output π. may also be specified with theterm.verboseconfig value <https://doc.rust-lang.org/cargo/reference/config.html>.-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>.--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 π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 find it, bestie, she always finds it π--frozen,--lockedβ either of these flags requires that theCargo.lockfile is up-to-date. if the lock file is missing, or it needs to be updated, Cargo will exit with an error π. the--frozenflag also prevents Cargo from attempting to access the network to determine if it is out-of-date.
these may be used in environments where you want to assert that the Cargo.lock file is up-to-date (like a CI build), or where you want to avoid network access entirely. very "i don't need the internet, i have myself" energy π
--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 babe: 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. π
may also be specified with the net.offline config value <https://doc.rust-lang.org/cargo/reference/config.html>.
β 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 π¦--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.
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>). yeah, it's exclusive. π
-h,--helpβ prints help information. the classic. π«Ά-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 π±
π EXIT STATUS π
0: Cargo succeeded. we love to see it π101: Cargo failed to complete. it's giving tragedy π
π 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)
and that's the whole page bestie, no cap π this was CARGO-PKGID(1), page one of the General Commands Manual, brought to you by the cargo crew. go get those fully qualified package specifiers, you absolute icon πβ¨
π¦ where this page comes from
- ubuntu jammy: cargo-1.76 1.76.0+dfsg0ubuntu1~bpo0-0ubuntu0.22.04.1 Β· Apache-2.0 WITH LLVM exception
- ubuntu noble: cargo-1.76 1.76.0+dfsg0ubuntu1-0ubuntu0.24.04.2 Β· 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