Skip to content

Commit 37b7845

Browse files
author
Derek
committed
fix: use rustup instead of distro packages for Rust toolchain
Ubuntu 24.04 ships rustc 1.75.0 which is too old for current cargo tools (bacon 3.22.0 requires 1.77+). Switch to rustup installer which always provides latest stable toolchain.
1 parent d9fb5d4 commit 37b7845

1 file changed

Lines changed: 70 additions & 17 deletions

File tree

  • ansible/roles/developer_core/tasks

ansible/roles/developer_core/tasks/rust.yml

Lines changed: 70 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,80 @@
11
---
22
# Rust toolchain and cargo tools installation
3+
# Uses rustup for Linux to get latest stable (distro packages are too old)
34

45
# ============================================================
5-
# Rust Installation (distro packages)
6+
# Rust Installation
67
# ============================================================
78

8-
- name: Install Rust and Cargo (Fedora)
9-
ansible.builtin.dnf:
10-
name:
11-
- rust
12-
- cargo
13-
- rustfmt
14-
- clippy
15-
state: present
9+
- name: Install Rust via rustup (Fedora)
10+
block:
11+
- name: Remove distro Rust packages if present (Fedora)
12+
ansible.builtin.dnf:
13+
name:
14+
- rust
15+
- cargo
16+
- rustfmt
17+
- clippy
18+
state: absent
19+
20+
- name: Install Rust via rustup (Fedora)
21+
ansible.builtin.shell:
22+
cmd: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
23+
creates: "{{ user_home }}/.cargo/bin/rustup"
24+
become: true
25+
become_user: "{{ actual_user }}"
26+
environment:
27+
CARGO_HOME: "{{ user_home }}/.cargo"
28+
RUSTUP_HOME: "{{ user_home }}/.rustup"
29+
30+
- name: Install Rust components via rustup (Fedora)
31+
ansible.builtin.command:
32+
cmd: "{{ user_home }}/.cargo/bin/rustup component add rustfmt clippy"
33+
become: true
34+
become_user: "{{ actual_user }}"
35+
environment:
36+
CARGO_HOME: "{{ user_home }}/.cargo"
37+
RUSTUP_HOME: "{{ user_home }}/.rustup"
38+
changed_when: true
39+
1640
when: ansible_facts['distribution'] == 'Fedora'
1741

18-
- name: Install Rust and Cargo (Ubuntu)
19-
ansible.builtin.apt:
20-
name:
21-
- rustc
22-
- cargo
23-
- rustfmt
24-
- rust-clippy
25-
state: present
42+
- name: Install Rust via rustup (Ubuntu)
43+
block:
44+
- name: Remove distro Rust packages if present (Ubuntu)
45+
ansible.builtin.apt:
46+
name:
47+
- rustc
48+
- cargo
49+
- rustfmt
50+
- rust-clippy
51+
state: absent
52+
53+
- name: Install curl for rustup (Ubuntu)
54+
ansible.builtin.apt:
55+
name: curl
56+
state: present
57+
58+
- name: Install Rust via rustup (Ubuntu)
59+
ansible.builtin.shell:
60+
cmd: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
61+
creates: "{{ user_home }}/.cargo/bin/rustup"
62+
become: true
63+
become_user: "{{ actual_user }}"
64+
environment:
65+
CARGO_HOME: "{{ user_home }}/.cargo"
66+
RUSTUP_HOME: "{{ user_home }}/.rustup"
67+
68+
- name: Install Rust components via rustup (Ubuntu)
69+
ansible.builtin.command:
70+
cmd: "{{ user_home }}/.cargo/bin/rustup component add rustfmt clippy"
71+
become: true
72+
become_user: "{{ actual_user }}"
73+
environment:
74+
CARGO_HOME: "{{ user_home }}/.cargo"
75+
RUSTUP_HOME: "{{ user_home }}/.rustup"
76+
changed_when: true
77+
2678
when: ansible_facts['distribution'] == 'Ubuntu'
2779

2880
- name: Install Rust via Homebrew (macOS)
@@ -86,6 +138,7 @@
86138
cargo_env:
87139
PATH: "{{ user_home }}/.cargo/bin:{{ ansible_facts['env'].PATH }}"
88140
CARGO_HOME: "{{ user_home }}/.cargo"
141+
RUSTUP_HOME: "{{ user_home }}/.rustup"
89142
when: ansible_facts['distribution'] in ['Fedora', 'Ubuntu']
90143

91144
- name: Set cargo environment (macOS)

0 commit comments

Comments
 (0)