Skip to content

Commit 2ddffdb

Browse files
committed
Assert nightly toolchain
1 parent 0fa305b commit 2ddffdb

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

packages/ferric/src/targets.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,39 @@ const THIRD_TIER_TARGETS: Set<TargetName> = new Set([
5858
"aarch64-apple-visionos",
5959
"aarch64-apple-visionos-sim",
6060
]);
61+
62+
export function assertNightlyToolchain() {
63+
const toolchainLines = cp
64+
.execFileSync("rustup", ["toolchain", "list"], {
65+
encoding: "utf-8",
66+
})
67+
.split("\n");
68+
69+
const nightlyLines = toolchainLines.filter((line) =>
70+
line.startsWith("nightly-"),
71+
);
72+
assertFixable(
73+
nightlyLines.length > 0,
74+
"You need to use a nightly Rust toolchain",
75+
{
76+
command: "rustup toolchain install nightly --component rust-src",
77+
},
78+
);
79+
80+
const componentLines = cp
81+
.execFileSync("rustup", ["component", "list", "--toolchain", "nightly"], {
82+
encoding: "utf-8",
83+
})
84+
.split("\n");
85+
assertFixable(
86+
componentLines.some((line) => line === "rust-src (installed)"),
87+
"You need to install the rust-src component for the nightly Rust toolchain",
88+
{
89+
command: "rustup toolchain install nightly --component rust-src",
90+
},
91+
);
92+
}
93+
6194
/**
6295
* Ensure the targets are either installed into the Rust toolchain or available via nightly Rust toolchain.
6396
* We do this up-front because the error message and fix is very unclear from the failure when missing.
@@ -78,6 +111,12 @@ export function ensureAvailableTargets(expectedTargets: Set<TargetName>) {
78111
command: `rustup target add ${[...missingInstallableTargets].join(" ")}`,
79112
},
80113
);
114+
115+
const expectedThirdTierTargets =
116+
expectedTargets.intersection(THIRD_TIER_TARGETS);
117+
if (expectedThirdTierTargets.size > 0) {
118+
assertNightlyToolchain();
119+
}
81120
}
82121

83122
export function isAndroidTarget(

0 commit comments

Comments
 (0)