Skip to content

Commit 72b39c1

Browse files
committed
setup: fix toolchain installation error
`cargo --version` is used to trigger the Rust toolchain installation but does not work currently and fails with the error: "error: toolchain 'nightly-....'is not installed" Use the `rustup toolchain install` instead. Signed-off-by: Yuan Zhuang <[email protected]> Reviewed-by: Zehui Chen <[email protected]> Reviewed-by: Sumit Garg <[email protected]>
1 parent ece214b commit 72b39c1

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

setup.sh

+6-8
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,17 @@ export CARGO_NET_GIT_FETCH_WITH_CLI=true
2828

2929
# install rustup and stable Rust if needed
3030
if command -v rustup &>/dev/null ; then
31-
# uninstall to avoid file corruption
32-
rustup uninstall stable && rustup install stable
31+
# 1. rustup early than 1.28 fails with `rustup toolchain install`
32+
# due to parameter mismatch. So self update first.
33+
# 2. uninstall to avoid file corruption
34+
rustup self update && rustup uninstall stable && rustup install stable
3335
else
3436
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
3537
source "$HOME/.cargo/env"
3638
fi
3739

38-
# Ensure the toolchain, components, and targets we've specified in
39-
# rust-toolchain.toml are ready to go. Since that file sets rustup's default
40-
# toolchain for the entire directory, all we need to do is run any
41-
# rustup-wrapped command to trigger installation. We've arbitrarily chosen
42-
# "cargo --version" since it has no other effect.
43-
cargo --version >/dev/null
40+
# install the Rust toolchain set in rust-toolchain.toml
41+
rustup toolchain install
4442

4543
##########################################
4644
# install toolchain

0 commit comments

Comments
 (0)