1CARGO-PKGID(1) General Commands Manual CARGO-PKGID(1)
2
3
4
6 cargo-pkgid - Print a fully qualified package specification
7
9 cargo pkgid [options] [spec]
10
12 Given a spec argument, print out the fully qualified package ID
13 specifier for a package or dependency in the current workspace. This
14 command will generate an error if spec is ambiguous as to which package
15 it refers to in the dependency graph. If no spec is given, then the
16 specifier for the local package is printed.
17
18 This command requires that a lockfile is available and dependencies
19 have been fetched.
20
21 A package specifier consists of a name, version, and source URL. You
22 are allowed to use partial specifiers to succinctly match a specific
23 package as long as it matches only one package. The format of a spec
24 can be one of the following:
25
26
27 ┌─────────────────┬───────────────────────────────────────────────────────┐
28 │SPEC Structure │ Example SPEC │
29 ├─────────────────┼───────────────────────────────────────────────────────┤
30 │name │ bitflags │
31 ├─────────────────┼───────────────────────────────────────────────────────┤
32 │name@version │ bitflags@1.0.4 │
33 ├─────────────────┼───────────────────────────────────────────────────────┤
34 │url │ https://github.com/rust-lang/cargo │
35 ├─────────────────┼───────────────────────────────────────────────────────┤
36 │url#version │ https://github.com/rust-lang/cargo#0.33.0 │
37 ├─────────────────┼───────────────────────────────────────────────────────┤
38 │url#name │ https://github.com/rust-lang/crates.io-index#bitflags │
39 ├─────────────────┼───────────────────────────────────────────────────────┤
40 │url#name:version │ https://github.com/rust-lang/cargo#crates-io@0.21.0 │
41 └─────────────────┴───────────────────────────────────────────────────────┘
42
44 Package Selection
45 -p spec, --package spec
46 Get the package ID for the given package instead of the current
47 package.
48
49 Display Options
50 -v, --verbose
51 Use verbose output. May be specified twice for "very verbose"
52 output which includes extra output such as dependency warnings and
53 build script output. May also be specified with the term.verbose
54 config value
55 <https://doc.rust-lang.org/cargo/reference/config.html>.
56
57 -q, --quiet
58 Do not print cargo log messages. May also be specified with the
59 term.quiet config value
60 <https://doc.rust-lang.org/cargo/reference/config.html>.
61
62 --color when
63 Control when colored output is used. Valid values:
64
65 • auto (default): Automatically detect if color support is
66 available on the terminal.
67
68 • always: Always display colors.
69
70 • never: Never display colors.
71
72 May also be specified with the term.color config value
73 <https://doc.rust-lang.org/cargo/reference/config.html>.
74
75 Manifest Options
76 --manifest-path path
77 Path to the Cargo.toml file. By default, Cargo searches for the
78 Cargo.toml file in the current directory or any parent directory.
79
80 --frozen, --locked
81 Either of these flags requires that the Cargo.lock file is
82 up-to-date. If the lock file is missing, or it needs to be updated,
83 Cargo will exit with an error. The --frozen flag also prevents
84 Cargo from attempting to access the network to determine if it is
85 out-of-date.
86
87 These may be used in environments where you want to assert that the
88 Cargo.lock file is up-to-date (such as a CI build) or want to avoid
89 network access.
90
91 --offline
92 Prevents Cargo from accessing the network for any reason. Without
93 this flag, Cargo will stop with an error if it needs to access the
94 network and the network is not available. With this flag, Cargo
95 will attempt to proceed without the network if possible.
96
97 Beware that this may result in different dependency resolution than
98 online mode. Cargo will restrict itself to crates that are
99 downloaded locally, even if there might be a newer version as
100 indicated in the local copy of the index. See the cargo-fetch(1)
101 command to download dependencies before going offline.
102
103 May also be specified with the net.offline config value
104 <https://doc.rust-lang.org/cargo/reference/config.html>.
105
106 Common Options
107 +toolchain
108 If Cargo has been installed with rustup, and the first argument to
109 cargo begins with +, it will be interpreted as a rustup toolchain
110 name (such as +stable or +nightly). See the rustup documentation
111 <https://rust-lang.github.io/rustup/overrides.html> for more
112 information about how toolchain overrides work.
113
114 -h, --help
115 Prints help information.
116
117 -Z flag
118 Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
119 details.
120
122 See the reference
123 <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
124 for details on environment variables that Cargo reads.
125
127 • 0: Cargo succeeded.
128
129 • 101: Cargo failed to complete.
130
132 1. Retrieve package specification for foo package:
133
134 cargo pkgid foo
135
136 2. Retrieve package specification for version 1.0.0 of foo:
137
138 cargo pkgid foo@1.0.0
139
140 3. Retrieve package specification for foo from crates.io:
141
142 cargo pkgid https://github.com/rust-lang/crates.io-index#foo
143
144 4. Retrieve package specification for foo from a local package:
145
146 cargo pkgid file:///path/to/local/package#foo
147
149 cargo(1), cargo-generate-lockfile(1), cargo-metadata(1)
150
151
152
153 CARGO-PKGID(1)