Skip to content

Commit 4b2afdd

Browse files
committed
Correcting based on review comments.
1 parent eaf5498 commit 4b2afdd

4 files changed

Lines changed: 16 additions & 40 deletions

File tree

src/rust/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ Installs Rust, common Rust utilities, and their required dependencies
1818
| version | Select or enter a version of Rust to install. | string | latest |
1919
| profile | Select a rustup install profile. | string | minimal |
2020
| targets | Optional comma separated list of additional Rust targets to install. | string | - |
21-
| customComponents | Optional a flag to allow installing rust components based on input. | boolean | false |
22-
| components | Optional comma separeated list of rust components to be installed based on input. | string | - |
21+
| components | Optional comma separeated list of rust components to be installed based on input. | string | rust-analyzer,rust-src,rustfmt,clippy |
2322

2423
## Customizations
2524

src/rust/devcontainer-feature.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "rust",
3-
"version": "1.4.1",
3+
"version": "1.5.0",
44
"name": "Rust",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/rust",
66
"description": "Installs Rust, common Rust utilities, and their required dependencies",
@@ -58,11 +58,6 @@
5858
"x86_64-unknown-redox,x86_64-unknown-uefi"
5959
]
6060
},
61-
"customComponents": {
62-
"type": "boolean",
63-
"default": false,
64-
"description": "Use custom components list instead of default components (rust-analyzer, rust-src, rustfmt, clippy)."
65-
},
6661
"components": {
6762
"type": "string",
6863
"default": "",

src/rust/install.sh

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
RUST_VERSION="${VERSION:-"latest"}"
1111
RUSTUP_PROFILE="${PROFILE:-"minimal"}"
1212
RUSTUP_TARGETS="${TARGETS:-""}"
13-
CUSTOM_COMPONENTS="${CUSTOMCOMPONENTS:-"false"}"
14-
RUST_COMPONENTS="${COMPONENTS:-""}"
13+
RUST_COMPONENTS="${COMPONENTS:-"rust-analyzer,rust-src,rustfmt,clippy"}"
1514

1615
export CARGO_HOME="${CARGO_HOME:-"/usr/local/cargo"}"
1716
export RUSTUP_HOME="${RUSTUP_HOME:-"/usr/local/rustup"}"
@@ -397,24 +396,19 @@ if [ "${UPDATE_RUST}" = "true" ]; then
397396
rustup update 2>&1
398397
fi
399398
# Install Rust components based on flag
400-
if [ "${CUSTOM_COMPONENTS}" = "true" ] && [ -n "${RUST_COMPONENTS}" ]; then
401-
echo "Installing custom Rust components..."
402-
IFS=',' read -ra components <<< "${RUST_COMPONENTS}"
403-
for component in "${components[@]}"; do
404-
# Trim leading and trailing whitespace
405-
component="${component#"${component%%[![:space:]]*}"}" && component="${component%"${component##*[![:space:]]}"}"
406-
if [ -n "${component}" ]; then
407-
echo "Installing Rust component: ${component}"
408-
if ! rustup component add "${component}" 2>&1; then
409-
echo "Warning: Failed to install component '${component}'. It may not be available for this toolchain." >&2
410-
exit 1
411-
fi
399+
echo "Installing Rust components..."
400+
IFS=',' read -ra components <<< "${RUST_COMPONENTS}"
401+
for component in "${components[@]}"; do
402+
# Trim leading and trailing whitespace
403+
component="${component#"${component%%[![:space:]]*}"}" && component="${component%"${component##*[![:space:]]}"}"
404+
if [ -n "${component}" ]; then
405+
echo "Installing Rust component: ${component}"
406+
if ! rustup component add "${component}" 2>&1; then
407+
echo "Warning: Failed to install component '${component}'. It may not be available for this toolchain." >&2
408+
exit 1
412409
fi
413-
done
414-
else
415-
echo "Installing common Rust dependencies..."
416-
rustup component add rust-analyzer rust-src rustfmt clippy 2>&1
417-
fi
410+
fi
411+
done
418412

419413
if [ -n "${RUSTUP_TARGETS}" ]; then
420414
IFS=',' read -ra targets <<< "${RUSTUP_TARGETS}"

test/rust/scenarios.json

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
"features": {
2222
"rust": {
2323
"version": "latest",
24-
"targets": "aarch64-unknown-linux-gnu",
25-
"customComponents": false
24+
"targets": "aarch64-unknown-linux-gnu"
2625
}
2726
}
2827
},
@@ -32,7 +31,6 @@
3231
"rust": {
3332
"version": "latest",
3433
"targets": "aarch64-unknown-linux-gnu",
35-
"customComponents": true,
3634
"components": "rust-analyzer,rust-src,rustfmt"
3735
}
3836
}
@@ -43,7 +41,6 @@
4341
"rust": {
4442
"version": "latest",
4543
"targets": "aarch64-unknown-linux-gnu",
46-
"customComponents": true,
4744
"components": "rust-analyzer,rust-src"
4845
}
4946
}
@@ -54,7 +51,6 @@
5451
"rust": {
5552
"version": "latest",
5653
"targets": "aarch64-unknown-linux-gnu",
57-
"customComponents": true,
5854
"components": "rust-analyzer,rust-src,rustfmt,clippy,rust-docs"
5955
}
6056
}
@@ -65,7 +61,6 @@
6561
"rust": {
6662
"version": "latest",
6763
"targets": "aarch64-unknown-linux-gnu",
68-
"customComponents": true,
6964
"components": ""
7065
}
7166
}
@@ -76,7 +71,6 @@
7671
"rust": {
7772
"version": "latest",
7873
"targets": "aarch64-unknown-linux-gnu",
79-
"customComponents": true,
8074
"components": "rust-analyzer,rust-src,rustfmt,clippy,rust-docs"
8175
}
8276
}
@@ -87,7 +81,6 @@
8781
"rust": {
8882
"version": "latest",
8983
"targets": "aarch64-unknown-linux-gnu",
90-
"customComponents": true,
9184
"components": "rust-analyzer,rust-src,rustfmt,clippy,rust-docs"
9285
}
9386
}
@@ -98,7 +91,6 @@
9891
"rust": {
9992
"version": "latest",
10093
"targets": "aarch64-unknown-linux-gnu",
101-
"customComponents": true,
10294
"components": "rust-analyzer,rust-src,rustfmt,clippy,rust-docs"
10395
}
10496
}
@@ -109,7 +101,6 @@
109101
"rust": {
110102
"version": "latest",
111103
"targets": "aarch64-unknown-linux-gnu",
112-
"customComponents": true,
113104
"components": "rust-analyzer,rust-src,rustfmt,clippy,rust-docs"
114105
}
115106
}
@@ -120,7 +111,6 @@
120111
"rust": {
121112
"version": "latest",
122113
"targets": "aarch64-unknown-linux-gnu",
123-
"customComponents": true,
124114
"components": "rust-analyzer,rust-src,rustfmt,clippy,rust-docs"
125115
}
126116
}
@@ -131,7 +121,6 @@
131121
"rust": {
132122
"version": "latest",
133123
"targets": "aarch64-unknown-linux-gnu",
134-
"customComponents": true,
135124
"components": "rust-analyzer,rust-src,rustfmt,clippy,rust-docs"
136125
}
137126
}
@@ -142,7 +131,6 @@
142131
"rust": {
143132
"version": "latest",
144133
"targets": "aarch64-unknown-linux-gnu",
145-
"customComponents": true,
146134
"components": "rust-analyzer,rust-src,rustfmt,clippy,rust-docs"
147135
}
148136
}

0 commit comments

Comments
 (0)