The merge request said "verified locally green" in its description, which in hindsight was asking for it.
It was the tail end of a big audit clean-up on go-tool-base, and one of the fixes came with a brand new end-to-end scenario: make sure generate add-flag doesn't throw away a command's aliases, shorthand flags and pre-run hooks when it regenerates. It passed on my machine. In CI, one scenario out of eighty-five fell over with this:
ERRO failed to load configuration: failed to load config: no configuration files found please run init, or provide a config file using the --config flag Now that's a funny thing to be told by gtb... because gtb doesn't have an init command.
The star and the stunt double
go-tool-base builds two binaries from one repository, and only one of them ever ships. ./cmd/gtb is the real tool, the generator you install. ./cmd/e2e is a test rig: it switches on every optional feature the framework has, init and doctor and config and the rest, so the end-to-end suite can exercise framework behaviour that a downstream tool inherits. It's there so I don't have to bake weird test fixtures into the real binary.
If gtb's the star, the e2e binary is its stunt double. It looks like the star, it answers to the same name (both call themselves gtb, so they even read the same config paths), and it's built to do the dangerous scenes. You just don't put it in the close-ups.
And the test harness had put it in the close-ups. The old helper promised one thing in its comment and built the other:
// BinaryPath returns the path to the compiled gtb binary, // building it on first call. The binary is placed in a temp directory // and reused for all subsequent calls. func BinaryPath() (string, error) { buildOnce.Do(func() { // ... binaryPath = filepath.Join(tmpDir, "gtb-e2e") cmd := exec.CommandContext(context.Background(), "go", "build", "-o", binaryPath, "./cmd/e2e") "The compiled gtb binary", it says, right above the line that builds the other one! All of the generator scenarios had been running against the stunt double.
Why the double needed a config
The reason it mattered comes down to a rule in the framework. Whether a missing config file is fatal depends on whether the tool is able to create one. A tool with an init command is expected to have run it, so no config is an error. A tool without one is allowed to start empty. In the bootstrap it's one line:
allowEmpty := props.Tool.IsDisabled(p.InitCmd) The real gtb disables init, so it runs happily with no config, same as in production. The stunt double enables init, so it demands one. And on my machine it found one. I have a perfectly real ~/.gtb/config.yaml from using the tool day to day. CI's clean runner had nothing of the sort.
The fix that would have hidden it
The first suggestion on the table was to give the scenario a config file of its own, the way another scenario already did. It would have gone green straight away. It would also have tested the generator with init switched on, which the real generator doesn't have, and buried the mismatch under a fixture.
What I typed back was "wait, what!!! the GTB binary should have the init FeatureCmd disabled and this not need a config file? is this the gtb binary or the e2e test binary". It was the e2e binary, naturally.
So the fix gave the generator scenarios the star. A second helper builds the real ./cmd/gtb, and the comment on it says why in more words than I'd normally allow, because this wasn't the first time I'd had that conversation and I didn't want a third:
// Generator scenarios must use this binary, not the e2e binary: the real // gtb tool disables InitCmd (internal/cmd/root), so its bootstrap treats a // missing config as allow-empty and the generate/regenerate/remove commands // run without an external config file — exactly as they do in production. func GeneratorBinaryPath() (string, error) { The pipeline went green, the e2e binary got a proper explanation in its package docs, and that was that... for about two months.
My clean check wasn't clean
Looking back at it now, the local re-check that "proved" the fix proved rather less than I thought. It emptied XDG_CONFIG_HOME to simulate a clean machine, but gtb reads ~/.gtb/, not anywhere XDG points, so my config was there in plain sight the whole time. (The very first attempt at that re-check also finished in 0.013 seconds, because I'd forgotten the environment variable that switches the suite on, and every scenario skipped without a word.) The green CI pipeline was the real proof, and mine just happened to agree with it.
And I suspect there was always a bigger problem behind the first one. Picking the right binary fixed which tool the tests ran, and did nothing about whose home they ran in. The generator steps launched gtb with no environment of their own, so they inherited mine: my config, my caches, my AI provider settings, the lot.
August, and a dressing room of its own
In August that kind of bug came back for a second go. A docs-generation path behaved differently on my machine, which had an AI provider configured, than on CI, which didn't, and a hash bug sailed through a green local run and failed a merge request's pipeline. The fix finally gave the generator steps a home of their own, the way the CLI steps had always had, and its commit message says the thing I should have written in June:
'Green locally, so CI is flaky' was the wrong conclusion, twice.
Isolating HOME wasn't free, though. Done naively, with the Go and lint caches stranded in the old home, the generator suite went from 193 seconds to 809 (uncomfortably close to CI's fifteen-minute limit). Pinning the module, build and lint caches back to shared locations brought it down to 119, which is faster than it was before any of this!
So June sorted out which binary ran and August sorted out where it lived, and these days the star and the stunt double each get changed in their own dressing room instead of mine.
Originally published at phpboyscout.uk on 24 November 2026.