CARGO-PKGID(1)

πŸ“¦ version 1.76.0, in ubuntu jammy, ubuntu noble

✨ 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:


πŸŽ€ OPTIONS πŸŽ€

πŸ‘‘ Package Selection

  • -p spec, --package spec β€” 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 the term.verbose config value <https://doc.rust-lang.org/cargo/reference/config.html>.
  • -q, --quiet β€” do not print cargo log messages. may also be specified with the term.quiet config value <https://doc.rust-lang.org/cargo/reference/config.html>.
  • --color when β€” 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-path path β€” path to the Cargo.toml file. by default, Cargo searches for the Cargo.toml file 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 the Cargo.lock file is up-to-date. if the lock file is missing, or it needs to be updated, Cargo will exit with an error 😭. the --frozen flag 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 to cargo begins with +, it will be interpreted as a rustup toolchain name (such as +stable or +nightly). see the rustup documentation <https://rust-lang.github.io/rustup/overrides.html> for more information about how toolchain overrides work πŸ¦‹
  • --config KEY=VALUE or PATH β€” overrides a Cargo configuration value. the argument should be in TOML syntax of KEY=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 ✨
  • -C PATH β€” 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 example cargo -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. 🫢
  • -Z flag β€” unstable (nightly-only) flags to Cargo. run cargo -Z help for 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 πŸ“

  1. retrieve package specification for foo package:
cargo pkgid foo
  1. retrieve package specification for version 1.0.0 of foo:
cargo pkgid foo@1.0.0
  1. retrieve package specification for foo from crates.io:
cargo pkgid https://github.com/rust-lang/crates.io-index#foo
  1. retrieve package specification for foo from 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