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

cargo search return non-zero exit code when no results found #11037

Closed
leighmcculloch opened this issue Aug 31, 2022 · 4 comments
Closed

cargo search return non-zero exit code when no results found #11037

leighmcculloch opened this issue Aug 31, 2022 · 4 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-search

Comments

@leighmcculloch
Copy link

Problem

Using cargo search in scripts is difficult because if it doesn't find any results it doesn't return a non-zero exit code.

Proposed Solution

Return a non-zero exit code when the search yields no results.

Notes

No response

@leighmcculloch leighmcculloch added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Aug 31, 2022
@epage
Copy link
Contributor

epage commented Aug 31, 2022

In what ways are you using cargo search in scripts? We don't provide a programmatic output mode for it, so it seems that either the value for using it in scripting is limited or its very brittle. By improving the scripting experience, I worry we send the wrong message about our compatibility on the text output.

@leighmcculloch
Copy link
Author

I'm using the output to check if a prior publish finalized.

Although I've also discovered the cargo add command can be used in the same way and it will return a non-zero exit code if the version of the crate cannot be found.

@epage
Copy link
Contributor

epage commented Sep 1, 2022

Some tools, like cargo-release, have support for that built-in.

You can also use the crate crates_index to look information up.

We are also looking at dedicated plumbing for the registry, see #11034

I lean towards closing this issue as the driving use case for using cargo search is is unreliable (considering we can return results from other crates) and there are other options.

@epage epage closed this as completed Sep 1, 2022
@epage
Copy link
Contributor

epage commented Sep 1, 2022

I should add that we also have #9507 where we want to add our own polling directly into cargo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-search
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants