Skip to content

Dependency pinning

A symbolic git ref, such as ref = "v0.4", can resolve to a different commit after a tag moves. trellis pin replaces it with a commit SHA and records the original ref in a comment on the same line. You can reproduce the pinned dependency and use --update to follow the recorded ref.

trellis pin [pkgs...] # resolve symbolic refs to SHAs, record the intent
trellis pin --update [pkgs...] # re-resolve each recorded intent to its latest SHA
trellis pin --check [pkgs...] # fail if a pinned SHA drifted from its tracked ref
trellis pin --unpin [pkgs...] # restore the symbolic refs

This is the consumer half of series tags: a release force-moves lat_cli-v0.4 so consumers can track the series, and pin is how a consumer follows that tag deliberately instead of silently. It also works with branches and tags from other tools.

pin scans [dependencies] and [dev-dependencies] of the selected packages, all of them when none are named, for git requirements whose ref is not already a full commit SHA. Each ref is resolved with git ls-remote <url> <ref>, so there is no clone, any host works, and authentication uses git’s configured credentials. An annotated tag pins the commit it points at, not the tag object. Then ref is rewritten and the original recorded in a # trellis:pin comment on the dependency’s own line:

packages/lat_cli/gleam.toml
[dependencies]
vestibule = { git = "https://github.com/example/monorepo.git", ref = "v0.4", path = "packages/vestibule" }
vestibule = { git = "https://github.com/example/monorepo.git", ref = "93deb4c38d4b3f5848681ff7e9d59883db751c67", path = "packages/vestibule" } # trellis:pin v0.4
Terminal window
$ trellis pin
[lat_cli] pinned vestibule 93deb4c tracking v0.4

Trellis preserves the rest of the file and updates the locked commit in manifest.toml without gleam update or Hex traffic. If the package has no lockfile, Gleam locks the pinned commit on its next dependency download.

Keep the # trellis:pin comment when copying a dependency to another manifest. Deleting it stops --update from following that dependency; the SHA stays pinned. Trellis also leaves hand-written SHAs without a pin comment unchanged.

--update re-resolves every recorded ref and rewrites the SHAs that moved:

Terminal window
$ trellis pin --update
[lat_cli] updated vestibule 51cbad6 was 93deb4c, tracking v0.4

The result is a plain gleam.toml diff to review, so following a moving tag becomes a deliberate, visible bump instead of a silent re-resolution. A dependency already at its ref’s tip is untouched.

--unpin restores every recorded ref and removes the comments, returning the manifest to its pre-pin text:

Terminal window
$ trellis pin --unpin
[lat_cli] unpinned vestibule restored v0.4

--check verifies that each pinned SHA is an ancestor of (or equal to) the commit its tracked ref points at now. A SHA no longer reachable from its ref indicates rewritten history:

Terminal window
$ trellis pin --check
drift: [lat_cli] `vestibule` is pinned at 51cbad6 which is not reachable from its tracked ref `v0.4` (now 8b9acd6) — the ref may have been force-moved

It exits 1 on any drift, so it drops straight into a PR gate:

# on: pull_request
- run: trellis pin --check

doctor runs the same check, but as an advisory warning: it needs the network, and re-pinning past a force-move is a supply-chain decision doctor --fix must not make. A network failure degrades to a warning too, so an offline doctor run stays useful. In --format json these findings use check: pinned_ref. See JSON output.

A pin that is merely behind its ref does not drift. A series tag moves forward once per release, and the old release commit stays an ancestor of the new one, so --check passes through ordinary releases. Use --update to advance a pin. Investigate rewritten history before accepting a new SHA.