Skip to content

The Drift Log · Model independence and repeatable builds

Fixing Locale Drift in Build Scripts

21 November 2026 · 3 min read · 602 words · established

Two identical sealed archive crates with matching checksum plates

Locale inheritance causes checksum drift in build scripts; pin LC_ALL=C to ensure byte-identical outputs across environments.

The failure you see in the build log

You check out last quarter’s source. You run the same CI script you used yesterday. The resulting archive has a different checksum. The diff is a handful of bytes in generated source files. The compiler version has not changed. The build tool’s string sorting is the cause.

Most build tools inherit the host’s locale. The locale determines collation order. When the tool enumerates files, generates code, or expands templates, it calls the system’s string‑comparison function. On a macOS machine with en_US.UTF‑8 the order is “a, b, c”. On a Linux container with C.UTF‑8 the order may be “A, a, B, b”. The generated file list changes, the generated code changes line order, the checksum changes.

The problem is invisible until you compare checksums. It is a classic reproducible‑build failure. The variance is deterministic given the locale, but the build environment is not version‑controlled, so the same source can produce different byte streams.

Why POSIX collation is a reliable baseline

POSIX collation (LC_ALL=C) defines a bytewise ordering of Unicode code points. It ignores language rules, case folding, and cultural conventions. When a tool uses POSIX collation, the order of strings is the same on every POSIX‑compatible platform. The ordering is repeatable, not merely statistically deterministic.

If a generator sorts a list of identifiers, the output will be identical on a developer’s laptop, on a CI runner, and on a hardened build server. The checksum of the resulting artifact will be stable. The build becomes part of a repeatable software pipeline, not a fragile script that leaks host state.

The trade‑off is that the generated output may not be human‑friendly for languages that expect locale‑aware sorting. For build artefacts this is acceptable. The goal is byte‑identical output, not user‑facing ordering.

Concrete steps to lock locale and collator state

First, set the locale at the start of every build script. Use the environment variable LC_ALL=C. Do not rely on the default inherited from the host.

#!/usr/bin/env bash
export LC_ALL=C
## rest of the build

Second, ensure that any language runtime respects the environment. In Node.js, pass an explicit locale string to Intl.Collator to force POSIX ordering.

const coll = new Intl.Collator('en', { usage: 'sort', sensitivity: 'variant' })
const sorted = items.sort(coll.compare)

Third, audit third‑party tools. Some generators expose a flag to set the collation mode. If a tool lacks such a flag, run it inside a container that defines LC_ALL=C.

Fourth, verify the effect with a checksum test. After the generation step, compute a hash of the produced file and compare it to a stored reference.

sha256sum generated.ts > generated.sha256

If the hash differs on two machines, the locale is still leaking. Iterate until the hash is stable.

Finally, record the locale setting in your repository’s documentation. Treat it as a build‑time invariant, similar to a pinned compiler version.

How SHPBL reduces this class of variance

SHPBL provides a model‑independent library whose release archives are sealed with published checksums. The same tooling is used across the MCP server, HTTP API, TypeScript SDK, and offline edition, so the same input yields the same byte stream when the environment’s locale is fixed. For details see the model‑independence pillar.

Monday’s action plan

Add export LC_ALL=C to the top of your CI build script. Run the generation step locally and record the SHA‑256 of the output. Commit the hash to the repo as a reference. On the next CI run, compare the new hash to the reference. If they match, you have eliminated the locale‑induced variance. If they differ, audit the tools that generate files and apply the same locale lock. This small change removes a common source of checksum drift and moves your pipeline closer to truly reproducible builds.

This post supports the longer argument in Model Independence and Repeatable Software Builds.

Keep reading

Next in the log

The Strategic Master Library · written and reviewed under the house's own epistemic rules: nothing claimed that we cannot show.