-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add cargo pkgid
for cargo-script
#14831
Comments
I've tried thinking it hard but not sure about the use case of getting |
This is less about the specific command and more about all of the places |
Regarding that, I feel like this should not block the stabilization. Unless there is a clear use case we want to support, I'd suggest we make sure pkgid not leaking when stabilization. |
I think a reasonable use case is that we don't include the |
@weihanglo package ids come up in
I don't see it being practical to skip this step to stabilizing this feature. |
$ cargo pkgid sql2.rs
path+file:///Users/rustin/code/rs-scripts/sql2.rs#embedded My hope is we can get away without a $ cargo pkgid sql2.rs -p clap
https://github.com/rust-lang/crates.io-index#clap:4.5.21 One problem with this is it is inferring $ cargo pkgid --manifest-path sql2.rs sql2.rs -p clap
https://github.com/rust-lang/crates.io-index#clap:4.5.21 At which point, the value of using a cargo-script file in a Having a short-hand for I would suggest we defer out a short-hand until someone requests it of us with a use case. |
By practical, did you mean from a technical perspective it's hard to make them out of the stabilization?
Could you share a practical use case of it? Anyway, I feel like a rename of the script can fix 90% of issues like this. |
To clarify, I'm not saying that using I don't know if I can name a specific concrete example of one that does this today but that I've personally run into enough |
Agree we shouldn't bother short-hand at this moment. One thing may be related to pkgid is executing a remote script. Something like
And if we ever want to support this combo, what does its pkgid look like? |
Yes.
The stated goal in the RFC is for first-class support. If we wanted something that half-way worked, we could have kept to I personally am regularly annoyed with the lack of Granted, how much we have stable in the first release is open for discussion. That depends on what level of quality people will expect from it being stable. However, as I said before, I don't see a way for us to have the package id spec format for cargo-scripts to be unstable. |
We don't support |
That is true. We may need a complete new source kind for it, not just for
It is indeed important to hear your voice as a user! You just convinced me that their supports is fairly essential. I still think it is not too hard to just ban |
If we don't put any $ cargo +nightly -Zscript metadata --manifest-path foo --format-version 1 | jq -r .resolve.root
warning: `package.edition` is unspecified, defaulting to `2021`
path+file:///Users/whlo/dev/dirty/foo#0.0.0
$ cargo +nightly metadata --manifest-path Cargo.toml --format-version 1 | jq -r .resolve.root
path+file:///Users/whlo/dev/dirty/foo#0.0.0 Note that |
A caller may want access to those features without wanting the package id field. A lot of custom commands (first or third-party) are built on top of |
I think some context is needed for this. Was that inside of Changing the protocol isn't the only solution. As I proposed in #14831 (comment), the output would be $ cargo +nightly -Zscript metadata --manifest-path foo --format-version 1 | jq -r .resolve.root
warning: `package.edition` is unspecified, defaulting to `2021`
path+file:///Users/whlo/dev/dirty/foo/foo#0.0.0
$ cargo +nightly metadata --manifest-path Cargo.toml --format-version 1 | jq -r .resolve.root
path+file:///Users/whlo/dev/dirty/foo#0.0.0
Oof, that limits our options. |
Yes. And I didn't realize your proposal is that. Thanks for the clarification. That seems probably the most simple way to extend both the spec and the implementation. |
Did you mean by: $ cargo pkgid sql2.rs
path+file:///Users/rustin/code/rs-scripts/sql2.rs |
@Rustin170506 |
@Rustin170506 if you are referring to #14831 (comment), I was quoting an example from you and replying to it, not intending to say that was what I was suggesting. Sorry for the confusion! |
Problem
ref #12207 (comment)
For now, if you try to use
cargo pkgid
against to a cargo script file. It will generate an error:Proposed Solution
We need to support
cargo pkgid
for cargo-script.For instance, for itself, it would look like:
For its dependencies, it would look like:
Notes
Not sure specifying the rust file as an argument is a good idea. Because
cargo pkgid
itself already takes theSPEC
as the argument. So it might be a very confusing syntax.The text was updated successfully, but these errors were encountered: