Skip to content

Commit 55469fb

Browse files
WorkerPantstdyas
andauthored
fix CI "build wheels" step for rustup no longer installing default toolchain (Cherry-pick of #22037) (#22039)
Fix the "Build wheels" step for a breaking change in [Rustup v1.28.0](https://blog.rust-lang.org/2025/03/02/Rustup-1.28.0.html) which no longer installs a default toolchain any more. Use `rustup default` to install the applicable toolchain because it is idempotent and will install the toolchain if it is not already installed. `rustup toolchain install` by design will try to install even if the toolchain is already installed. See rust-lang/rustup#710 for discussion of this distinction. Closes #22036 --------- Co-authored-by: Tom Dyas <[email protected]>
1 parent 60f59d9 commit 55469fb

File tree

3 files changed

+54
-8
lines changed

3 files changed

+54
-8
lines changed

.github/workflows/release.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ jobs:
3535
3636
echo "${HOME}/.cargo/bin" >> $GITHUB_PATH
3737
38+
'
39+
- name: Install Rust toolchain
40+
run: '# Set the default toolchain. Installs the toolchain if it is not already
41+
installed.
42+
43+
rustup default 1.82.0
44+
45+
cargo version
46+
3847
'
3948
- name: Expose Pythons
4049
run: 'echo "/opt/python/cp37-cp37m/bin" >> $GITHUB_PATH
@@ -116,6 +125,15 @@ jobs:
116125
117126
echo "${HOME}/.cargo/bin" >> $GITHUB_PATH
118127
128+
'
129+
- name: Install Rust toolchain
130+
run: '# Set the default toolchain. Installs the toolchain if it is not already
131+
installed.
132+
133+
rustup default 1.82.0
134+
135+
cargo version
136+
119137
'
120138
- name: Expose Pythons
121139
run: 'echo "/opt/python/cp37-cp37m/bin" >> $GITHUB_PATH

.github/workflows/test.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,14 @@ jobs:
354354
355355
echo "${HOME}/.cargo/bin" >> $GITHUB_PATH
356356
357+
'
358+
- name: Install Rust toolchain
359+
run: '# Set the default toolchain. Installs the toolchain if it is not already installed.
360+
361+
rustup default 1.82.0
362+
363+
cargo version
364+
357365
'
358366
- name: Expose Pythons
359367
run: 'echo "/opt/python/cp37-cp37m/bin" >> $GITHUB_PATH
@@ -418,6 +426,14 @@ jobs:
418426
419427
echo "${HOME}/.cargo/bin" >> $GITHUB_PATH
420428
429+
'
430+
- name: Install Rust toolchain
431+
run: '# Set the default toolchain. Installs the toolchain if it is not already installed.
432+
433+
rustup default 1.82.0
434+
435+
cargo version
436+
421437
'
422438
- name: Expose Pythons
423439
run: 'echo "/opt/python/cp37-cp37m/bin" >> $GITHUB_PATH

src/python/pants_release/generate_github_workflows.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -312,16 +312,28 @@ def rust_channel() -> str:
312312
return cast(str, rust_toolchain["toolchain"]["channel"])
313313

314314

315-
def install_rustup() -> Step:
316-
return {
317-
"name": "Install rustup",
318-
"run": dedent(
319-
"""\
315+
def install_rustup() -> list[Step]:
316+
return [
317+
{
318+
"name": "Install rustup",
319+
"run": dedent(
320+
"""\
320321
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -v -y --default-toolchain none
321322
echo "${HOME}/.cargo/bin" >> $GITHUB_PATH
322323
"""
323-
),
324-
}
324+
),
325+
},
326+
{
327+
"name": "Install Rust toolchain",
328+
"run": dedent(
329+
f"""\
330+
# Set the default toolchain. Installs the toolchain if it is not already installed.
331+
rustup default {rust_channel()}
332+
cargo version
333+
"""
334+
),
335+
},
336+
]
325337

326338

327339
def install_pythons(versions: list[str]) -> Step:
@@ -832,7 +844,7 @@ def build_wheels_job(
832844
if container:
833845
initial_steps = [
834846
*checkout(containerized=True, ref=for_deploy_ref),
835-
install_rustup(),
847+
*install_rustup(),
836848
{
837849
"name": "Expose Pythons",
838850
"run": dedent(

0 commit comments

Comments
 (0)