Skip to main content

Module toolchain

Module toolchain 

Source
Expand description

Toolchains: the ones this repository declares, and what is installed for them.

Relevance is decided by the repository, not by the machine. A toolchain appears in the snapshot when a file in the checkout declares it — Cargo.toml for Rust, package.json for Node — and never because the executable happens to be on the path: a laptop with nine language runtimes installed would otherwise report all nine for every repository, and the one line that matters would be lost among them.

Declared, installed and available are three different facts and are kept apart. A repository can ask for a version nobody has; a machine can have a version nobody asked for; and the interesting case — they disagree — is only visible when both are reported.

Asking a version costs a process spawn each, so it happens in a full resolution only; a fast resolution takes the answers from the cache and says unknown when it has none.

Structs§

Detector
One toolchain this executable knows how to recognise.
Marker
One place a toolchain may be declared.

Enums§

Declares
How a declared version is read out of the file that declares it. Small on purpose: three shapes cover every manifest here, and a fourth is a new variant rather than a parser.
Pin
What a declared version asks of the installed one. A .nvmrc that says 22 pins a release line; a rust-version of 1.85 is a floor that 1.90 satisfies. Reading the second as the first reports every up-to-date machine as wrong.

Constants§

DETECTORS
Every toolchain this executable can recognise, in the order a snapshot reports them.
VERSION_TIMEOUT
How long a version subprocess may take before it is abandoned. A toolchain shim that downloads a release on first use has been seen to take minutes; a snapshot reports unknown rather than waiting for it.

Functions§

declared
The toolchains this repository declares, without asking any of them their version. Cheap enough for the hot path: one exists() per marker, one directory read for a marker with a *, and one small file read for each that matched.
read_text
Read the declared version out of one marker file.
satisfies
Whether an installed version satisfies a declared one, or None when that cannot be decided. Only plain dotted numbers are compared: a range (>=22), a channel name (stable) or an answer that is not a version stays undecided, because a finding that guesses fires on machines that are fine, and is then ignored when it is right.
with_installed
Ask every declared toolchain what is installed. One bounded subprocess each; a toolchain that is not on the path is ToolchainAvailability::Missing, and one that does not answer within VERSION_TIMEOUT stays Unknown.