Repository navigation
LWLP-4934: Pin cargo/rustc wrappers to the image Rust toolchain - #174
Open
Jonathan Gangi (JAVGan) wants to merge 2 commits into
Open
Jonathan Gangi (JAVGan) wants to merge 2 commits into
Jonathan Gangi (JAVGan) wants to merge 2 commits into
Conversation
Crates and build backends can ship a rust-toolchain.toml (uv_build's sdist pins 1.97.1), which makes rustup install that exact toolchain at build time. Wheel builds run with network isolation, so the download can never succeed (rustup fails on DNS for static.rust-lang.org), and it is not hermetic. Export RUSTUP_TOOLCHAIN in the cargo and rustc wrappers, defaulting to the installed RUST_VERSION. The env var takes precedence over rust-toolchain.toml, so rustup uses the image toolchain. Callers can still set RUSTUP_TOOLCHAIN or use cargo +<toolchain> to pick another installed toolchain. The rustup wrapper is unchanged so toolchain management commands keep working. Add an image-build probe that a rust-toolchain.toml pin to an uninstalled version does not change what cargo and rustc report. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Jonathan Gangi <jgangi@redhat.com>
Jonathan Gangi (JAVGan)
force-pushed
the
fix/LWLP-4934-rustup-toolchain-override
branch
from
December 4, 2026 15:45
e2528c4 to
a0220c6
Compare
Jonathan Gangi (JAVGan)
marked this pull request as ready for review
December 4, 2026 15:45
…lchain The cargo/rustc wrappers now use the image toolchain regardless of a crate's rust-toolchain pin. Rust is backward compatible, so that is fine for a pin that is the same as or older than the image, but a newer pin would silently build with an older compiler than the crate asks for. Add rust-pin-check.sh, called by both wrappers when RUSTUP_TOOLCHAIN is not set by the caller. It finds the nearest rust-toolchain.toml (or legacy rust-toolchain) at or above the working directory, as rustup does, and exits non-zero when the pinned version is newer than the image's RUST_VERSION. stable and partial versions (1.97) are handled; beta, nightly and unparsable channels fail closed. Unit tests cover the comparison and file lookup. The image-build probe now also checks that an older/equal/stable pin uses the image toolchain and that a newer, nightly or beta pin fails. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Jonathan Gangi <jgangi@redhat.com>
Jonathan Gangi (JAVGan)
force-pushed
the
fix/LWLP-4934-rustup-toolchain-override
branch
from
December 4, 2026 19:49
22e8311 to
183f487
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jira: LWLP-4934
Problem
uv_buildships arust-toolchain.tomlpinning its own Rust channel (1.97.1 for 0.11.33). When maturin runs cargo in that tree, rustup tries to install the exact pinned toolchain at build time. Under the forced network isolation from #165/netguard this can never succeed: with the #140 group-writableRUSTUP_HOMEworkaround in place, rustup gets past the permission error and then fails on DNS forstatic.rust-lang.org(see the findings on LWLP-4934). It is also not hermetic. Upgrading Rust alone does not help, because pins are matched exactly (tested, see the closed #168).Change
build_scripts/build-rust.sh: thecargoandrustcwrappers now exportRUSTUP_TOOLCHAIN=${RUSTUP_TOOLCHAIN:-<RUST_VERSION>}. The env var takes precedence overrust-toolchain.toml, so rustup uses the installed toolchain and never tries to download another. A caller can still setRUSTUP_TOOLCHAINor usecargo +<toolchain>for another already-installed toolchain. Therustupwrapper is unchanged.build_scripts/rust-pin-check.sh(installed as/usr/local/libexec/lightwell-rust-pin-check, called by both wrappers when the caller has not setRUSTUP_TOOLCHAIN): Rust is backward compatible, so the image toolchain must be the same as or newer than a pin. The nearestrust-toolchain.toml(or legacyrust-toolchain) at or above the working directory is checked, like rustup does. A pin newer thanRUST_VERSIONfails with a message naming the file, the pin and the image version.stableand partial versions (1.97) are accepted;beta,nightlyand unparsable channels fail closed because they cannot be compared.tests/unit/test_rust_pin_check.py: 25 cases for the comparison, file lookup (parent directories, nearest wins, legacy file, quoting) and error exit codes.tests/check_runtime.py: image-build probe that older, equal, partial andstablepins use the image toolchain (cargo/rustc --versionunchanged) and that a pin one patch or one minor newer,nightlyandbetaall fail with therust-pin-checkmessage.Trade-off
Crates build with the image's Rust instead of the version upstream pinned (when that is older). That is a provenance decision, taken in discussion on LWLP-4934 to avoid maintaining a list of pre-installed toolchains. A newer pin is refused rather than built with an older compiler.
Verification (end to end, in
lightwell-python-tenant)Images were built from this change (base from
183f487; the CLI image additionally had a test-onlyContainerfile.clipin to that base, since removed from this branch).OK: rust-toolchain.toml pins: older or equal use the image, newer fail), so in the real image older/equal/partial/stablepins use the image toolchain and newer/nightly/betapins fail.python-build-kx999: python-socketio 5.16.2, target SCRATCH, builds refcumulative/5.16.2/pipeline-19272782, wheel server disabled souv_buildis built from source. Succeeded (clone, source-to-sdist, fromager-build-wheels, clamav-scan all passed).uv_build0.11.33 (pinned 1.97.1, older than the image's 1.98.1) andmaturin1.16.0 were compiled from source, with norust-pin-checkfailure, nosyncing channel, and nostatic.rust-lang.orgreferences in the log.a0220c6, no guard) also succeeded (python-build-xqkzq). On images without the override it failed: Rust bump only hitrustup/tmp: Permission denied; build-rust: make rustup's install paths group-writable for crate-pinned toolchains #140 workaround only hitdns errorfetchingchannel-rust-1.97.1.toml.sha256under netguard.A run with the wheel server enabled passes on any image, because all dependencies (including
uv_build) come pre-built from the validated index, so it does not exercise this path.🤖 Generated with Claude Code