Include uv's target triple in version report#18520
Conversation
Report the target triple (e.g., `x86_64-unknown-linux-gnu`) as part of `uv self version` in both text and JSON output formats. The `RUST_HOST_TARGET` env var is already set at build time in build.rs. https://claude.ai/code/session_014pVEoFck1PabYcMqTbQEyC
Place the target triple after the date within the parentheses, e.g., `uv 0.10.10 (7b6a515 2026-03-16 x86_64-unknown-linux-gnu)` instead of outside them. https://claude.ai/code/session_014pVEoFck1PabYcMqTbQEyC
`RUST_HOST_TARGET` is always set by Cargo at build time via `build.rs`, so use `env!` to make this a compile-time guarantee rather than treating it as optional. https://claude.ai/code/session_014pVEoFck1PabYcMqTbQEyC
The `target_triple` field now appears as `null` in project version JSON output since it was added to the `VersionInfo` struct. https://claude.ai/code/session_014pVEoFck1PabYcMqTbQEyC
Use `skip_serializing_if` on `commit_info` and `target_triple` so they are omitted from JSON output when `None` (i.e., for project versions) rather than appearing as `null`. https://claude.ai/code/session_014pVEoFck1PabYcMqTbQEyC
Remove `skip_serializing_if` from `commit_info` to preserve backwards compatibility. Add a TODO to skip it in the next breaking release. https://claude.ai/code/session_014pVEoFck1PabYcMqTbQEyC
Separate the version structs so each type only contains relevant fields: - `SelfVersionInfo`: has `commit_info` and `target_triple` (non-optional) - `ProjectVersionInfo`: has `commit_info` for backwards compat (with TODO to remove in a breaking release), no `target_triple` https://claude.ai/code/session_014pVEoFck1PabYcMqTbQEyC
| /// Name of the package (always "uv"). | ||
| package_name: String, |
There was a problem hiding this comment.
I wonder if we should drop this now?
There was a problem hiding this comment.
Is it still relevant for uvx --version?
| /// Version information for a project (`uv version`). | ||
| #[derive(Serialize)] | ||
| pub struct ProjectVersionInfo { | ||
| /// Name of the package. | ||
| pub package_name: Option<String>, | ||
| /// Version, such as "0.5.1". | ||
| version: String, | ||
| /// Information about the git commit uv was built from. | ||
| /// | ||
| /// Always `null` for project versions, kept for backwards compatibility. | ||
| // TODO(zanieb): Remove this field in a breaking release. | ||
| commit_info: Option<CommitInfo>, | ||
| } |
There was a problem hiding this comment.
I didn't want to add more nullable fields to the project version struct, so here we are.
Gankra
left a comment
There was a problem hiding this comment.
Are there other places where we expose rust target triples to users? Presumably yes? (And either way it's kinda fine since this is presumably for people reporting bugs to us).
| VersionInfo { | ||
| package_name: Some("uv".to_owned()), | ||
| // Target triple is set by Cargo via `build.rs` | ||
| let target_triple = env!("RUST_HOST_TARGET").to_string(); |
There was a problem hiding this comment.
Did you do a manual check that this contains the right thing in practice? Weird obscure env-var to me.
There was a problem hiding this comment.
❯ cargo run -q self version
uv 0.10.10+29 (50c71922f 2026-03-17 aarch64-apple-darwin)
There was a problem hiding this comment.
What the heck where did this come from though?
There was a problem hiding this comment.
Oh, we copied https://github.com/rust-lang/cargo/blob/5ef1b854cb899425bb11c89b24a623cd35d215fb/build.rs#L15-L16
previously
Lines 22 to 23 in 3e22637
you freaked me out :D
Co-authored-by: Aria Desires <aria.desires@gmail.com>
When looking at #18509 I realized this would be useful
e.g.,