-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(info): default to local without explicit reg #16358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(info): default to local without explicit reg #16358
Conversation
66fac81 to
5dca6df
Compare
5dca6df to
c911e65
Compare
9f62061 to
97cb792
Compare
When no registry is specified in the cargo info command, default to using the local crates.io registry.
3582f4f to
0984acc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔢 Self-check (PR reviewed by myself and ready for feedback)
-
Code compiles successfully
-
Unit tests added
-
All tests pass
-
Comments added where necessary
-
PR title and description updated
-
Documentation Updated(or confirmed not needed)
-
PR size is reasonable
r? @epage
I am not sure if it is worth keeping/asserting the output directory because, in these cases, we will not update the project itself. However, keeping it may help us prevent future changes that could affect them. Please let me know if you have a strong opinion on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a bug in cargo info where it would incorrectly query the default registry instead of inspecting a local package when a default registry is configured but not explicitly specified.
Key Changes:
- Modified
cargo infoto prefer local packages when no explicit--registryor--indexflag is provided - Added detection for explicit registry/index arguments using
args._contains() - Added logic to override registry selection when a local package exists and no explicit registry is specified
Reviewed changes
Copilot reviewed 14 out of 32 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/bin/cargo/commands/info.rs |
Added logic to detect explicit --registry or --index flags and pass this information to the info operation |
src/cargo/ops/registry/info/mod.rs |
Modified to accept explicit_registry parameter and prefer local packages when no explicit registry is specified |
tests/testsuite/cargo_info/mod.rs |
Registered two new test modules for the fix |
tests/testsuite/cargo_info/with_default_registry_configured/* |
Test case verifying local package is used when default registry is configured but not explicitly specified |
tests/testsuite/cargo_info/with_default_registry_configured_and_specified/* |
Test case verifying registry package is used when explicitly specified with --registry flag |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks for your review! 💚 💙 💜 💛 ❤️ |
Update cargo submodule 27 commits in 2c283a9a5c5968eeb9a8f12313f04feb1ff8dfac..c46423de7351e3c4c734b2faa86088a9f5d1302b 2025-12-04 16:47:28 +0000 to 2025-12-12 23:16:12 +0000 - feat(report): cargo report timings HTML replay (rust-lang/cargo#16377) - feat: stabilize `-Zconfig-include` (rust-lang/cargo#16284) - fix(package): Don't verify registry for --list (rust-lang/cargo#16341) - Fixed incorrect locking logic when artifact-dir == build-dir (rust-lang/cargo#16385) - feat(log): make timing messages ready for HTML replay (rust-lang/cargo#16382) - chore(deps): update msrv (1 version) to v1.92 (rust-lang/cargo#16381) - Downgrade curl-sys to 0.4.83 (rust-lang/cargo#16379) - fix(timing): more self-contained timing/log data (rust-lang/cargo#16378) - test: update to `proc_macro::tracked::path` (rust-lang/cargo#16380) - refactor(lint): move lints to separate modules (rust-lang/cargo#16364) - fix(index): Apply feedback from Cargo team (rust-lang/cargo#16369) - fix(lints): handle lints separately at ws pkg level (rust-lang/cargo#16367) - feat(lint): new `implicit_minimum_version_req` lint (rust-lang/cargo#16321) - fix(info): default to local without explicit reg (rust-lang/cargo#16358) - Remove `[no-mentions]` handler in our triagebot config (rust-lang/cargo#16361) - Don't read the config file twice when $CARGO_HOME is a symlink (rust-lang/cargo#16325) - fix(timings): forgot to negate filter (rust-lang/cargo#16352) - fix(doctest): Include all search paths with new build layout (rust-lang/cargo#16348) - fix(layout): Remove hashes from bins in new layout (rust-lang/cargo#16351) - docs(faq): Include an entry on disk space (rust-lang/cargo#16349) - feat(timings): derive concurrency data from unit data (rust-lang/cargo#16350) - perf(layout): Use unit_id, not pkg hash, for bin/lib pkg_dirs for new layout (rust-lang/cargo#16345) - Validate target source paths before compilation with clearer errors (rust-lang/cargo#16338) - test(doc): Remove unused build script (rust-lang/cargo#16344) - refactor(timings): store UnitData in RenderContext instead (rust-lang/cargo#16346) - perf(clean): Optimize (legacy) clean with multiple -p specifiers (rust-lang/cargo#16264) - test: Adjust output for out-of-tree build-dir (rust-lang/cargo#16343)
Update cargo submodule 29 commits in 2c283a9a5c5968eeb9a8f12313f04feb1ff8dfac..e91b2baa632c0c7e84216c91ecfe107c37d887c1 2025-12-04 16:47:28 +0000 to 2025-12-13 16:29:21 +0000 - refactor(lints): move from cargo::util::lints to cargo::lints (rust-lang/cargo#16392) - test(lint): redact more due to line got omitted (rust-lang/cargo#16391) - feat(report): cargo report timings HTML replay (rust-lang/cargo#16377) - feat: stabilize `-Zconfig-include` (rust-lang/cargo#16284) - fix(package): Don't verify registry for --list (rust-lang/cargo#16341) - Fixed incorrect locking logic when artifact-dir == build-dir (rust-lang/cargo#16385) - feat(log): make timing messages ready for HTML replay (rust-lang/cargo#16382) - chore(deps): update msrv (1 version) to v1.92 (rust-lang/cargo#16381) - Downgrade curl-sys to 0.4.83 (rust-lang/cargo#16379) - fix(timing): more self-contained timing/log data (rust-lang/cargo#16378) - test: update to `proc_macro::tracked::path` (rust-lang/cargo#16380) - refactor(lint): move lints to separate modules (rust-lang/cargo#16364) - fix(index): Apply feedback from Cargo team (rust-lang/cargo#16369) - fix(lints): handle lints separately at ws pkg level (rust-lang/cargo#16367) - feat(lint): new `implicit_minimum_version_req` lint (rust-lang/cargo#16321) - fix(info): default to local without explicit reg (rust-lang/cargo#16358) - Remove `[no-mentions]` handler in our triagebot config (rust-lang/cargo#16361) - Don't read the config file twice when $CARGO_HOME is a symlink (rust-lang/cargo#16325) - fix(timings): forgot to negate filter (rust-lang/cargo#16352) - fix(doctest): Include all search paths with new build layout (rust-lang/cargo#16348) - fix(layout): Remove hashes from bins in new layout (rust-lang/cargo#16351) - docs(faq): Include an entry on disk space (rust-lang/cargo#16349) - feat(timings): derive concurrency data from unit data (rust-lang/cargo#16350) - perf(layout): Use unit_id, not pkg hash, for bin/lib pkg_dirs for new layout (rust-lang/cargo#16345) - Validate target source paths before compilation with clearer errors (rust-lang/cargo#16338) - test(doc): Remove unused build script (rust-lang/cargo#16344) - refactor(timings): store UnitData in RenderContext instead (rust-lang/cargo#16346) - perf(clean): Optimize (legacy) clean with multiple -p specifiers (rust-lang/cargo#16264) - test: Adjust output for out-of-tree build-dir (rust-lang/cargo#16343)
Update cargo submodule 29 commits in 2c283a9a5c5968eeb9a8f12313f04feb1ff8dfac..e91b2baa632c0c7e84216c91ecfe107c37d887c1 2025-12-04 16:47:28 +0000 to 2025-12-13 16:29:21 +0000 - refactor(lints): move from cargo::util::lints to cargo::lints (rust-lang/cargo#16392) - test(lint): redact more due to line got omitted (rust-lang/cargo#16391) - feat(report): cargo report timings HTML replay (rust-lang/cargo#16377) - feat: stabilize `-Zconfig-include` (rust-lang/cargo#16284) - fix(package): Don't verify registry for --list (rust-lang/cargo#16341) - Fixed incorrect locking logic when artifact-dir == build-dir (rust-lang/cargo#16385) - feat(log): make timing messages ready for HTML replay (rust-lang/cargo#16382) - chore(deps): update msrv (1 version) to v1.92 (rust-lang/cargo#16381) - Downgrade curl-sys to 0.4.83 (rust-lang/cargo#16379) - fix(timing): more self-contained timing/log data (rust-lang/cargo#16378) - test: update to `proc_macro::tracked::path` (rust-lang/cargo#16380) - refactor(lint): move lints to separate modules (rust-lang/cargo#16364) - fix(index): Apply feedback from Cargo team (rust-lang/cargo#16369) - fix(lints): handle lints separately at ws pkg level (rust-lang/cargo#16367) - feat(lint): new `implicit_minimum_version_req` lint (rust-lang/cargo#16321) - fix(info): default to local without explicit reg (rust-lang/cargo#16358) - Remove `[no-mentions]` handler in our triagebot config (rust-lang/cargo#16361) - Don't read the config file twice when $CARGO_HOME is a symlink (rust-lang/cargo#16325) - fix(timings): forgot to negate filter (rust-lang/cargo#16352) - fix(doctest): Include all search paths with new build layout (rust-lang/cargo#16348) - fix(layout): Remove hashes from bins in new layout (rust-lang/cargo#16351) - docs(faq): Include an entry on disk space (rust-lang/cargo#16349) - feat(timings): derive concurrency data from unit data (rust-lang/cargo#16350) - perf(layout): Use unit_id, not pkg hash, for bin/lib pkg_dirs for new layout (rust-lang/cargo#16345) - Validate target source paths before compilation with clearer errors (rust-lang/cargo#16338) - test(doc): Remove unused build script (rust-lang/cargo#16344) - refactor(timings): store UnitData in RenderContext instead (rust-lang/cargo#16346) - perf(clean): Optimize (legacy) clean with multiple -p specifiers (rust-lang/cargo#16264) - test: Adjust output for out-of-tree build-dir (rust-lang/cargo#16343)
Update cargo submodule 29 commits in 2c283a9a5c5968eeb9a8f12313f04feb1ff8dfac..e91b2baa632c0c7e84216c91ecfe107c37d887c1 2025-12-04 16:47:28 +0000 to 2025-12-13 16:29:21 +0000 - refactor(lints): move from cargo::util::lints to cargo::lints (rust-lang/cargo#16392) - test(lint): redact more due to line got omitted (rust-lang/cargo#16391) - feat(report): cargo report timings HTML replay (rust-lang/cargo#16377) - feat: stabilize `-Zconfig-include` (rust-lang/cargo#16284) - fix(package): Don't verify registry for --list (rust-lang/cargo#16341) - Fixed incorrect locking logic when artifact-dir == build-dir (rust-lang/cargo#16385) - feat(log): make timing messages ready for HTML replay (rust-lang/cargo#16382) - chore(deps): update msrv (1 version) to v1.92 (rust-lang/cargo#16381) - Downgrade curl-sys to 0.4.83 (rust-lang/cargo#16379) - fix(timing): more self-contained timing/log data (rust-lang/cargo#16378) - test: update to `proc_macro::tracked::path` (rust-lang/cargo#16380) - refactor(lint): move lints to separate modules (rust-lang/cargo#16364) - fix(index): Apply feedback from Cargo team (rust-lang/cargo#16369) - fix(lints): handle lints separately at ws pkg level (rust-lang/cargo#16367) - feat(lint): new `implicit_minimum_version_req` lint (rust-lang/cargo#16321) - fix(info): default to local without explicit reg (rust-lang/cargo#16358) - Remove `[no-mentions]` handler in our triagebot config (rust-lang/cargo#16361) - Don't read the config file twice when $CARGO_HOME is a symlink (rust-lang/cargo#16325) - fix(timings): forgot to negate filter (rust-lang/cargo#16352) - fix(doctest): Include all search paths with new build layout (rust-lang/cargo#16348) - fix(layout): Remove hashes from bins in new layout (rust-lang/cargo#16351) - docs(faq): Include an entry on disk space (rust-lang/cargo#16349) - feat(timings): derive concurrency data from unit data (rust-lang/cargo#16350) - perf(layout): Use unit_id, not pkg hash, for bin/lib pkg_dirs for new layout (rust-lang/cargo#16345) - Validate target source paths before compilation with clearer errors (rust-lang/cargo#16338) - test(doc): Remove unused build script (rust-lang/cargo#16344) - refactor(timings): store UnitData in RenderContext instead (rust-lang/cargo#16346) - perf(clean): Optimize (legacy) clean with multiple -p specifiers (rust-lang/cargo#16264) - test: Adjust output for out-of-tree build-dir (rust-lang/cargo#16343)
What does this PR try to resolve?
close #16145
93c2c40(#16358) shouldn't be an error; it should inspect the local package correctly.The reason it is buggy is as follows: The
default_registryfunction attempts to retrieve the default registry from the user's configuration; in this case, it is crates-io.In this PR, I modified the cargo-info to prefer the local package if the registry is not explicitly specified.
How to test and review this PR?
Check the unit test.
r? @ghost