Repository navigation
fix(version): tolerate missing VERGEN_GIT_DESCRIBE on crates.io builds - #3124
Conversation
`version_str()` read the git-describe version with `env!`, which requires
the variable to be present at compile time. Building from the crates.io
package archive has no git worktree, so the build script can't set
`VERGEN_GIT_DESCRIBE` and compilation fails:
error: environment variable `VERGEN_GIT_DESCRIBE` not defined at compile time
Switch to `option_env!`, which yields `None` when the variable is unset,
and fall back to the cargo package version — the same fallback already
used for vergen's IDEMPOTENT placeholder. Extract the choice into a pure
`resolve_version` helper with unit tests covering the available,
idempotent, and absent cases.
Closes #3123
Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Claude <[email protected]>
|
@worktrunk-bot has this always been the case? can we add an integration test so this can't happen please? |
A regression to env!("VERGEN_GIT_DESCRIBE") only breaks builds where no
ancestor is a git repo (a user's ~/.cargo/registry from `cargo install`),
so cargo publish's in-tree verify build can't catch it — it finds the
outer repo's .git. Guard the mechanism directly instead: scan src/ and
fail if any VERGEN_* variable is read with env! rather than option_env!.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Has this always been the case? Yes — since The reason it slipped past release CI is subtle: Integration test: added in |
let's have a more integration-y test, even if only in nightly or similar I'm still skeptical that it has been broken for that long and no one mentioned it! are we sure? |
The existing guard scans src/ for `env!` on VERGEN_* vars — fast, runs on every PR, but only checks the mechanism. Add the integration-y test the maintainer asked for: package the crate as `cargo publish` does, extract it where `git describe` finds no `.git` (GIT_CEILING_DIRECTORIES fences ancestor discovery), build `wt`, and assert it both compiles and falls back to the cargo version. This reproduces the exact `cargo install` / `~/.cargo/registry` condition #3123 hit — before the fix it failed to compile. `#[ignore]` (full from-scratch build, ~minutes); run in a new `crate-build` nightly job via `--ignored`. Verified locally: build emits "Unable to set VERGEN_GIT_DESCRIBE" yet succeeds, and `wt --version` reports 0.59.0. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Are we sure it's been broken that long? Yes — and it was noticed; it just never reached an upstream issue, because every from-source packager independently worked around it in their own recipe. I verified directly:
Three independent packagers all carry the identical workaround. And I confirmed the published archive really ships the bug: I downloaded the Why end-users didn't file it: the README's primary channels (Homebrew, winget, pacman) install prebuilt binaries built in-tree during release CI (where More integration-y test ( I ran it locally — the build emits the real-world signature and still succeeds: Before the |
|
what does PRQL do, in comparison? |
|
What PRQL does: essentially the same setup as worktrunk before this fix, plus a runtime fallback that doesn't actually cover the crates.io case. Its let git = GitBuilder::default().describe(true, true, None).build()?;
Emitter::default().add_instructions(&git)?.emit()?;But let git_version = env!("VERGEN_GIT_DESCRIBE");
let cargo_version = env!("CARGO_PKG_VERSION");
Version::parse(git_version).or_else(|_| Version::parse(cargo_version))The catch: that So our (One thing that would flip this: if PRQL pins a vergen version/config that emits Sources: PRQL build.rs · PRQL compiler_version · vergen README · vergen #299 |
|
you're totally right about fwiw |
|
though actually @worktrunk-bot I'm now getting errors (before this merge) on a local build. Maybe this is a new failure? test it with previous versions |
Release v0.60.0 (minor bump from 0.59.0). Minor because semver-checks flagged a breaking library-API change and five new features landed since v0.59.0. The data-loss surface review (4 independent finders) cleared the one change that touches it (relocating dirty linked worktrees, #3104). ### Improved - Package installs now complete branch/worktree names via dynamic registration (#3105, thanks @bendrucker) - `wt step relocate` moves dirty linked worktrees (#3104, thanks @lunaynx for reporting) - `--dry-run` previews print to stdout (#3085) - Picker gutter distinguishes local (`/`) and remote (`|`) branches (#3115) - `wt list --format=json` gains structured `repo`/`ci.repo` metadata (#3021, thanks @jeremy0dell) - `wt step eval --format=json` (#3106) - `--format=claude-code` rejected on `wt list` / `wt config state get` (#3116) ### Fixed - `cargo install worktrunk` builds from crates.io again (#3124, fixes #3123, thanks @kerrickstaley for reporting) - Tab-completion works in repos with no commits (#3097, closes #3094) - `wt config state get ci-status --format=json` honors `[forge].platform` (#3120) ### Documentation - `wt list --help` example tables fit the terminal (#3125) - `/wt-switch-create` cross-repo handling reworked (#3118) - Help-text and web-doc refinements (#3096, #3108, #3110, #3112, #3126) Full notes in `CHANGELOG.md`. > _This was written by Claude Code on behalf of max_
|
You're right to suspect this — it's a new failure, introduced at
The cause isn't the
So How I verifiedFor each version: downloaded
The merged |
|
OK nice! Do a full search of other places where we might later find a problem, because it's an "outer loop" sort of problem |
|
Did a full sweep of the "build/package environment differs from the dev checkout" class — the outer loop where CI is green but The full set of compile-time external dependencies#3123 was one instance of a general pattern: something read at compile time that exists in our git checkout but may be absent in a packaged build. There are exactly three mechanisms in the crate that do this:
A missing file in any of these fails the build at compile time — exactly the #3123 failure mode, just a different macro. The askama one is the easiest to overlook because nothing in I confirmed all of them are currently safe in every packaged environment:
The gap: detection is mostly outer-loopThe mechanism guard (
So the realistic future regression isn't the four files above — it's someone adding a new Suggested fix (turn it inner-loop)A fast sibling to Want me to open a PR with that guard test? |
|
yes please! |
|
Opened #3130. It adds a fast guard ( |
…ilds (#3130) Follow-up to #3124, requested in [this thread](#3124 (comment)): turn the "build/package environment differs from the dev checkout" class inner-loop. #3123 (`env!("VERGEN_GIT_DESCRIBE")` failing on the crates.io archive) was one instance of a general pattern — *something read at compile time that exists in our git checkout but may be absent in a packaged build*. There are three mechanisms in the crate that do this, and a missing file in any of them is a hard compile error, exactly the #3123 failure mode: | Mechanism | Embeds | |-----------|--------| | `include_str!` / `include_bytes!` | `dev/*.example.toml`, `dev/opencode-plugin.ts`, `gemini-extension.json` | | askama `#[template(path = …)]` (reads files at compile time via proc-macro) | `templates/{bash.sh,zsh.zsh,fish.fish,fish_wrapper.fish,nushell.nu,powershell.ps1}` | The detection gap: a plain `cargo build`/`cargo test` always sees these files (they're in the working tree), so it can never catch a packaging drop. Today that's only caught by the nightly Nix build (slow) or by crates.io itself after publish (the worst loop). The realistic future regression is someone adding a new `include_str!("../../assets/foo")` or `#[template]` outside the currently-packaged dirs — it passes every PR check, then breaks Nix that night and `cargo install` at the next release. This adds a fast guard (`embedded_assets_ship_in_package`, no build, runs on every PR) that scans `src/` for every embedded path and asserts each is: 1. **present in `cargo package --list`** — so it ships in the crates.io archive (the #3123 surface), and 2. **covered by the `flake.nix` source filter** — so it survives the Nix build. Both currently pass. I verified the test isn't vacuous: pointing an `include_str!` at a tracked-but-unpackaged file (`tests/helpers/wt-perf/src/lib.rs`) fails it with both violations reported, distinct from the compiler's own "file not found" for a path that doesn't exist at all. This sits alongside the existing `version_build.rs` guards (the fast `env!`-vs-`option_env!` mechanism check on every PR, and the `#[ignore]`d full-archive build in nightly), extending the same philosophy to the file-presence half of the class. Co-authored-by: worktrunk-bot <[email protected]> Co-authored-by: Claude Opus 4.8 <[email protected]>
worktrunk 0.60.0 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>## Release Notes ### Improved - **Package installs complete branch and worktree names**: A plain `brew install worktrunk` (or other package install) now tab-completes branch and worktree names, not just subcommands and flags. `wt config shell completions <shell>` emits a dynamic registration that calls the binary at completion time (the maintained `clap_complete::env` path), matching what `gh`, `rustup`, and `kubectl` ship. ([#3105](max-sixty/worktrunk#3105), thanks @bendrucker) - **`wt step relocate` moves dirty linked worktrees**: Relocating a linked worktree with uncommitted or untracked changes no longer skips it. `git worktree move` carries those files along, so the dirty-skip was a worktrunk policy rather than a git limitation. The main worktree still skips when dirty (without `--commit`), since its relocation falls back to `git checkout`, which refuses to switch over a dirty tree. ([#3104](max-sixty/worktrunk#3104), thanks @lunaynx for reporting) - **`--dry-run` previews print to stdout**: `wt hook <type>`, `wt step relocate`, `wt step prune`, `wt step copy-ignored`, and `wt config shell install`/`uninstall` now send their `--dry-run` preview to stdout (the command's answer) while narration stays on stderr. This matches `wt list`, `git clean -n`, and `terraform plan`, and keeps previews pageable and pipeable. (Breaking: scripts reading these previews from stderr should now read stdout) ([#3085](max-sixty/worktrunk#3085)) - **Picker gutter distinguishes local and remote branches**: With `--branches` and `--remotes`, the `wt switch` picker marks each row's kind in the gutter: `/` for a local branch without a worktree and `|` for a remote branch, alongside the existing `@`/`^`/`+` worktree glyphs. ([#3115](max-sixty/worktrunk#3115)) - **`wt list --format=json` gains structured `repo` metadata**: JSON output adds `repo` (the local checkout's primary remote) and `ci.repo` (the repository `ci.url` targets, which differs for fork PRs) objects carrying `host`/`owner`/`name`/`provider`; the existing `repo_url` and `ci.repo_url` strings remain. The provider honors the configured `[forge].platform` on hosts that can't be auto-detected. ([#3021](max-sixty/worktrunk#3021), thanks @jeremy0dell) - **`wt step eval --format=json`**: `wt step eval` gains a structured `{name, template, result}` JSON lane on stdout, the machine-readable analog of its `-v` view. Text mode is unchanged. ([#3106](max-sixty/worktrunk#3106)) - **`--format=claude-code` rejected where it never applied**: `wt list` and `wt config state get` accepted `--format=claude-code` silently and treated it as `table`; the value only ever meant anything on `wt list statusline`. Both now fail fast with `invalid value 'claude-code'`. (Breaking: `wt list --format=claude-code` and `wt config state get --format=claude-code` now error) ([#3116](max-sixty/worktrunk#3116)) ### Fixed - **`cargo install worktrunk` builds from crates.io**: Installing from crates.io failed to compile with `environment variable VERGEN_GIT_DESCRIBE not defined at compile time`, because the package archive has no `.git` for the build script to read. The version lookup now falls back to the cargo package version when git-describe is unavailable. ([#3124](max-sixty/worktrunk#3124), fixes [#3123](max-sixty/worktrunk#3123), thanks @kerrickstaley for reporting) - **Tab-completion works in repos with no commits**: `wt switch <TAB>` and `wt remove <TAB>` returned nothing on a fresh `git init` repo, because the unborn default branch has no entry under `refs/heads/`. Completion now also draws on worktree branches, so the unborn `main` (and any `wt switch --create` branch on an empty repo) completes. ([#3097](max-sixty/worktrunk#3097), closes [#3094](max-sixty/worktrunk#3094)) - **`wt config state get ci-status --format=json` honors `[forge].platform`**: On a self-hosted host the parser can't recognize (Gitea, Azure DevOps, GitHub Enterprise on a generic domain), this path reported `provider: "unknown"` while `wt list --format=json` reported the configured provider. All structured-output paths now route the `[forge].platform` override through one accessor, so they stay consistent. ([#3120](max-sixty/worktrunk#3120)) ### Documentation - **`wt list --help` example tables fit the terminal**: The captured `wt list` example tables in `--help` chop to terminal width with a dimmed ellipsis (matching real `wt list`) instead of word-wrapping and shearing their columns; hand-authored command examples still wrap. ([#3125](max-sixty/worktrunk#3125)) - **`/wt-switch-create` cross-repo handling reworked**: The Claude Code plugin command's skill reworks how it creates and enters a worktree in another repo, built around what the harness actually does (`EnterWorktree` re-roots within the current repo; a `cd` reaches another repo when it's in `additionalDirectories`). The procedure dropped from five steps to three. ([#3118](max-sixty/worktrunk#3118)) - **Help-text and docs refinements**: `--format` help renders its values inline (`[possible values: table, json]`) instead of an expanded block; `wt switch` and `wt step push` help got smaller clarifications; and web-doc terminal blocks no longer wrap command-only lines. ([#3096](max-sixty/worktrunk#3096), [#3108](max-sixty/worktrunk#3108), [#3110](max-sixty/worktrunk#3110), [#3112](max-sixty/worktrunk#3112), [#3126](max-sixty/worktrunk#3126)) ## Install worktrunk 0.60.0 ### Install prebuilt binaries via shell script ```sh curl --proto '=https' --tlsv1.2 -LsSf https://github.com/max-sixty/worktrunk/releases/download/v0.60.0/worktrunk-installer.sh | sh && wt config shell install ``` ### Install prebuilt binaries via powershell script ```sh powershell -ExecutionPolicy Bypass -c "irm https://github.com/max-sixty/worktrunk/releases/download/v0.60.0/worktrunk-installer.ps1 | iex"; git-wt config shell install ``` ### Install prebuilt binaries via Homebrew ```sh brew install worktrunk && wt config shell install ``` ## Download worktrunk 0.60.0 | File | Platform | Checksum | |--------|----------|----------| | [worktrunk-aarch64-apple-darwin.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.60.0/worktrunk-aarch64-apple-darwin.tar.xz) | Apple Silicon macOS | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.60.0/worktrunk-aarch64-apple-darwin.tar.xz.sha256) | | [worktrunk-x86_64-apple-darwin.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.60.0/worktrunk-x86_64-apple-darwin.tar.xz) | Intel macOS | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.60.0/worktrunk-x86_64-apple-darwin.tar.xz.sha256) | | [worktrunk-x86_64-pc-windows-msvc.zip](https://github.com/max-sixty/worktrunk/releases/download/v0.60.0/worktrunk-x86_64-pc-windows-msvc.zip) | x64 Windows | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.60.0/worktrunk-x86_64-pc-windows-msvc.zip.sha256) | | [worktrunk-aarch64-unknown-linux-musl.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.60.0/worktrunk-aarch64-unknown-linux-musl.tar.xz) | ARM64 MUSL Linux | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.60.0/worktrunk-aarch64-unknown-linux-musl.tar.xz.sha256) | | [worktrunk-x86_64-unknown-linux-musl.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.60.0/worktrunk-x86_64-unknown-linux-musl.tar.xz) | x64 MUSL Linux | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.60.0/worktrunk-x86_64-unknown-linux-musl.tar.xz.sha256) | ### Install via Cargo ```sh cargo install worktrunk && wt config shell install ``` ### Install via Winget (Windows) ```sh winget install max-sixty.worktrunk && git-wt config shell install ``` ### Install via AUR (Arch Linux) ```sh paru worktrunk-bin && wt config shell install ``` </pre> <p>View the full release notes at <a href="https://github.com/max-sixty/worktrunk/releases/tag/v0.60.0">https://github.com/max-sixty/worktrunk/releases/tag/v0.60.0</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!11933
Problem
cargo install worktrunkfails to build from crates.io:version_str()reads the git-describe version with theenv!macro, which requires the variable to exist at compile time. Thevergen_gitclbuild script can only setVERGEN_GIT_DESCRIBEwhen building inside a git worktree. The crates.io package archive has no.git, so the build script emitsUnable to set VERGEN_GIT_DESCRIBEand never defines the variable — andenv!then fails to compile.Solution
Switch
env!→option_env!, which yieldsNonewhen the variable is unset instead of failing to compile, and fall back to the cargo package version. That fallback is exactly what the existingIDEMPOTENTbranch already does, so the behavior is unchanged for normal builds. The choice is extracted into a pureresolve_version(Option<&str>, &str)helper with unit tests.Testing
Reproduced the failure the same way crates.io builds the package —
cargo packageproduces the source archive, which I extracted to a non-git directory and built:environment variable VERGEN_GIT_DESCRIBE not defined at compile time.Unable to set VERGEN_GIT_DESCRIBEwarning remains), andwt --versionreports0.59.0(the cargo version fallback).New unit tests cover the three
resolve_versioncases: git-describe available, vergenIDEMPOTENTplaceholder, and absent (None— the crates.io case).Closes #3123 — automated triage