Bootstrap bugs: templ version skew + .gitignore _templ.go pattern mismatch #8

Open
opened 2026-07-19 10:13:34 +00:00 by mathias · 0 comments
Owner

Two latent bugs surfaced building a real project (mathias/cad-atlas) from this template, 2026-07-19. Both bite every child repo on first build.

1. templ version skew (build-breaking)

go.mod pins github.com/a-h/templ v0.2.778, but CI installs templ@latest (currently v0.3.x). The v0.3 generator emits templruntime.WriteString, which does not exist in the v0.2.778 runtime:

internal/web/index_templ.go:44:38: undefined: templruntime.WriteString

So task check / go build fails on a freshly generated repo.

Fix: pin the generator and runtime to the same minor. Either bump go.mod to the current templ (go get -u github.com/a-h/templ@latest + regenerate) and pin CI to a matching templ@vX.Y.Z, or hold both at v0.2.778. Don't let CI float to @latest against a pinned runtime.

2. .gitignore pattern doesn't match templ output

Pattern is *.templ.go (dot). templ actually emits *_templ.go (underscore). Generated files are therefore not ignored and leak into git add -A.

Fix: change the pattern to *_templ.go.

Repro

# create from template, then:
go install github.com/a-h/templ/cmd/templ@latest
templ generate && go build ./...   # → undefined: templruntime.WriteString
git add -A && git status           # → index_templ.go / layout_templ.go staged (should be ignored)

Related brain note: wiki/homelab/decisions/cad-atlas-audit-chain-is-viz-data.md (template-go-web footguns section). Also note the known no-go.sum-shipped behavior (child runs go mod tidy).

Two latent bugs surfaced building a real project (`mathias/cad-atlas`) from this template, 2026-07-19. Both bite every child repo on first build. ## 1. templ version skew (build-breaking) `go.mod` pins `github.com/a-h/templ v0.2.778`, but CI installs `templ@latest` (currently v0.3.x). The v0.3 generator emits `templruntime.WriteString`, which does not exist in the v0.2.778 runtime: ``` internal/web/index_templ.go:44:38: undefined: templruntime.WriteString ``` So `task check` / `go build` fails on a freshly generated repo. **Fix:** pin the generator and runtime to the same minor. Either bump `go.mod` to the current templ (`go get -u github.com/a-h/templ@latest` + regenerate) and pin CI to a matching `templ@vX.Y.Z`, or hold both at v0.2.778. Don't let CI float to `@latest` against a pinned runtime. ## 2. `.gitignore` pattern doesn't match templ output Pattern is `*.templ.go` (dot). templ actually emits `*_templ.go` (underscore). Generated files are therefore **not** ignored and leak into `git add -A`. **Fix:** change the pattern to `*_templ.go`. ## Repro ```bash # create from template, then: go install github.com/a-h/templ/cmd/templ@latest templ generate && go build ./... # → undefined: templruntime.WriteString git add -A && git status # → index_templ.go / layout_templ.go staged (should be ignored) ``` Related brain note: `wiki/homelab/decisions/cad-atlas-audit-chain-is-viz-data.md` (template-go-web footguns section). Also note the known no-`go.sum`-shipped behavior (child runs `go mod tidy`).
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mathias/template-go-web#8