Skip to content

Include uv's target triple in version report#18520

Merged
zanieb merged 10 commits intoastral-sh:mainfrom
zaniebot:claude/add-target-triple-version-l77b5
Mar 19, 2026
Merged

Include uv's target triple in version report#18520
zanieb merged 10 commits intoastral-sh:mainfrom
zaniebot:claude/add-target-triple-version-l77b5

Conversation

@zanieb
Copy link
Copy Markdown
Member

@zanieb zanieb commented Mar 16, 2026

When looking at #18509 I realized this would be useful

e.g.,

$ uv self version
0.0.0 (53b0f5d92 2023-10-19 x86_64-unknown-linux-gnu)

claude added 2 commits March 16, 2026 18:14
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
@zanieb zanieb added the enhancement New feature or improvement to existing functionality label Mar 16, 2026
claude added 4 commits March 16, 2026 19:22
`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
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 17, 2026

Merging this PR will not alter performance

✅ 5 untouched benchmarks


Comparing zaniebot:claude/add-target-triple-version-l77b5 (0e75b67) with main (c276064)

Open in CodSpeed

Comment on lines +23 to +24
/// Name of the package (always "uv").
package_name: String,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should drop this now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it still relevant for uvx --version?

Comment on lines +35 to +47
/// 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>,
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to add more nullable fields to the project version struct, so here we are.

@zanieb zanieb requested a review from Gankra March 17, 2026 12:54
@zanieb zanieb marked this pull request as ready for review March 17, 2026 12:54
Copy link
Copy Markdown
Contributor

@Gankra Gankra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you do a manual check that this contains the right thing in practice? Weird obscure env-var to me.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❯ cargo run -q self version
uv 0.10.10+29 (50c71922f 2026-03-17 aarch64-apple-darwin)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What the heck where did this come from though?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, we copied https://github.com/rust-lang/cargo/blob/5ef1b854cb899425bb11c89b24a623cd35d215fb/build.rs#L15-L16

previously

let target = std::env::var(EnvVars::TARGET).unwrap();
println!("cargo:rustc-env=RUST_HOST_TARGET={target}");

you freaked me out :D

zanieb and others added 2 commits March 18, 2026 22:36
Co-authored-by: Aria Desires <aria.desires@gmail.com>
@zanieb zanieb enabled auto-merge (squash) March 19, 2026 03:58
@zanieb zanieb merged commit 481d99b into astral-sh:main Mar 19, 2026
131 of 133 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or improvement to existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants