Skip to content

Docker RUST_VERSION can drift from rust-toolchain.toml silently #371

Open

Description

@SDL-A1

docker/build.Dockerfile pins the compiler twice over:

ARG RUST_VERSION=1.93.1
...
ENV RUSTUP_TOOLCHAIN=${RUST_VERSION}

with a comment saying # Keep in step with rust-toolchain.toml. The
RUSTUP_TOOLCHAIN line is there deliberately, to stop rustup fetching the
components rust-toolchain.toml asks for.

The cost is that the two can drift silently. Bump rust-toolchain.toml and
the Docker build keeps using the old compiler, with nothing failing — local
builds and shipped binaries are simply built by different versions, and the
difference shows up as a bug that reproduces in one place and not the other.

A comment is the weakest possible enforcement for an invariant that has to
hold across two files.

Options, in rough order of preference:

  1. Read the version from rust-toolchain.toml in the build, so there is
    one source of truth.
  2. Assert it: a CI step that parses both and fails when they differ.
    Cheap, and it turns a silent drift into a red check.
  3. Leave the comment and accept the risk, which is what we have now.

Arrived with #366.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions