Skip to content

.cargo/config.toml causes cargo info to only read from registry, not local files #16145

@BatmanAoD

Description

@BatmanAoD

Problem

This is the inverse of #14810.

Based on the design discussions and documentation of cargo info, it should use local Cargo.toml files when the current directory is a crate or workspace containing the specified crate. (Side-note: I would have expected that spec wouldn't be necessary when inside a single crate; is there a good reason for not making spec optional in that case?)

However, it always seems to use the default registry regardless of what my current directory is. In addition to not showing a local filepath, the behaviors I've observed are:

  • If I add a feature locally, that feature is not listed.
  • If I try to use cargo info for a crate that is not published or is published in a non-default registry (without providing the --registry argument), the tool prints:
         Updating crates.io index
    error: could not find `<spec>` in registry `https://github.com/rust-lang/crates.io-index`
    

With --offline, the "Updating crates.io index" line is skipped, but I get the same behavior.

Update: this is apparently due to my use of .cargo/config.toml. See below.

Steps

  1. Create a local crate.
  2. Create .cargo/config.toml that explicitly sets registry.default to crates-io.
  3. Run cargo info <name>.

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.89.0 (c24e10642 2025-06-23)
release: 1.89.0
commit-hash: c24e1064277fe51ab72011e2612e556ac56addf7
commit-date: 2025-06-23
host: aarch64-apple-darwin
libgit2: 1.9.0 (sys:0.20.2 vendored)
libcurl: 8.7.1 (sys:0.4.80+curl-8.12.1 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 3.5.0 8 Apr 2025
os: Mac OS 15.7.1 [64-bit]

Metadata

Metadata

Assignees

Labels

C-bugCategory: bugCommand-infoS-needs-mentorStatus: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions