Skip to content
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

Something like cargo query or cargo info for information about a registry package #948

Closed
tomjakubowski opened this issue Nov 21, 2014 · 16 comments · Fixed by #14141
Closed
Labels
A-new-subcommand Area: new subcommand S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

Comments

@tomjakubowski
Copy link
Contributor

It would be nice to be able to get the description, latest version(s), author, license, and the like, for a given registry package. Prior art includes npm view and gem query.

Somewhat related/complementary to #925

@alexcrichton alexcrichton added the A-new-subcommand Area: new subcommand label Nov 21, 2014
@DiamondLovesYou
Copy link
Contributor

👍

@felixc
Copy link
Contributor

felixc commented Jan 10, 2016

Now that cargo supports external installable sub-commands, does this make more sense to add via that mechanism, rather than being built-in?

That said, given that cargo search presumably already does most of this, maybe it just needs to get some new flags to print more info?

@alexcrichton
Copy link
Member

@felixc yeah I'd be in favor of seeing this bake externally first

@g-k
Copy link

g-k commented Mar 15, 2016

I gave this a shot: https://github.com/g-k/cargo-show. I'm curious about how people might use it and how to improve it for them.

For example, I'd like to cache package GET requests like crates.io, but I'm not sure if it'd be better to use a sub command specific cache like ~/.cargo-show/ or a shared cache that other sub commands could use like ~/.cargo/cache/package-details/.

@PaulDance
Copy link
Contributor

@tomjakubowski Is it still desirable today considering the possibility of simply using the linked tool?

@epage
Copy link
Contributor

epage commented Mar 15, 2022

There is also https://crates.io/crates/cargo-info which has stalled out.

@epage epage added the S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. label May 3, 2023
@epage
Copy link
Contributor

epage commented May 24, 2023

A thought I had on this command is that it cargo info <dep> would choose the latest version of <dep> in the associated Cargo.lock file and show that. If the user specifies cargo info <dep>@<ver>, ver would act like cargo install and would be a = version requirement.

We could also show either cargo tree -i <dep> or tell the user about the command. Similarly, cargo search could suggest cargo info

We could also show feature activation, either baesd on if <dep> is a direct dependency of the relevant manifest (showing a view like cargo add) or based on resolving the dependency graph (behaving more like cargo tree).

Some prior art

@epage
Copy link
Contributor

epage commented Oct 31, 2023

Looks like #6666 is covered by existing commands but could still be useful to either highlight those commands or to include their output

@yugaego
Copy link

yugaego commented Nov 15, 2023

The previously linked package cargo-info provides the requested functionality (thanks, @epage).

In my opinion, info or show command (or a new search flag for that matter) is a good candidate to become a built-in solution. First of all, it exposes useful -- sometimes even necessary -- information on packages, improving search experience and discoverability of packages. It is also quite an expected command for a package manager, so its absence may be felt as a significant lack.
(f.i., I've spent a lot of time trying to find out which cargo command outputs package's info before finding this thread.)

@Rustin170506
Copy link
Member

Rustin170506 commented Dec 7, 2023

Hi folks, we developed 'cargo-information' as a solution for this issue. You can try it out now.

You can try it through cargo install cargo-information or cargo install cargo-information --git https://github.com/hi-rustin/cargo-information.git.

Features:

  • Works with all registries that are compatible with Cargo
  • Fetches and displays basic package information (name, version, owners, etc.)
  • Shows package dependencies and their versions
  • Provides information about package features

If you have any questions, please feel free to open an issue and discuss it with us. Additionally, we are currently having several design discussions ongoing. We would appreciate your valuable input and insights.

@2ndDerivative
Copy link

How does this work with other registries? I'm assuming with have to extend the standard web API for this or does this use another mechanism than API queries?

@Rustin170506
Copy link
Member

How does this work with other registries? I'm assuming with have to extend the standard web API for this or does this use another mechanism than API queries?

It uses the standard download API to download it into the cargo cache dir. Then we can inspect from the local mainfist.

@2ndDerivative
Copy link

Would adding a web API endpoint for a crate detail lookup functionality be an option? Could save cargo the download + unzip and make the data accessible for other programs too.

@Rustin170506
Copy link
Member

Would adding a web API endpoint for a crate detail lookup functionality be an option? Could save cargo the download + unzip and make the data accessible for other programs too.

If you require to get metadata from crates.io, I think in crates.io we already have this API, but it has a very strict API rate limitation (1 request / second).

The challenge here is it's very difficult to ask all the registries to implement this new API. And for Cargo, we can always download it and parse the manifest. So it seems like there isn't much enthusiasm to add that API to the registry specification.

@epage
Copy link
Contributor

epage commented Jan 4, 2024

If the concern is with a lot of extra .crate files, the upcoming GC should help

@linyihai
Copy link
Contributor

linyihai commented Aug 2, 2024

A thought I had on this command is that it cargo info would choose the latest version of in the associated Cargo.lock file and show that.

Really want this feature.

Now that querying a dependent version requires a manual search to the lock file, I'm not sure if there's a better way. It would be nice to be able to use a command to actualize each of the dependent versions in the lock file

@bors bors closed this as completed in f3fee6d Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-new-subcommand Area: new subcommand S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Projects
None yet
Development

Successfully merging a pull request may close this issue.