macOSでrustup update時に「error: component 'rls-preview' for target 'aarch64-apple-darwin' is unavailable for download for channel 'stable'」というエラーが発生した場合の対処法

## 背景

ある日 `rustup update` を実行したら以下のエラーが発生しました。

```sh
$ rustup update
info: syncing channel updates for 'stable-aarch64-apple-darwin'
info: latest update on 2025-05-15, rust version 1.87.0 (17067e9ac 2025-05-09)
error: component 'rls-preview' for target 'aarch64-apple-darwin' is unavailable for download for channel 'stable'
error: One or many components listed above might have been permanently removed from newer versions
error: of the official Rust distribution due to deprecation.
error: 
error: You can find the list of removed components at
error: <https://rust-lang.github.io/rustup/devel/concepts/components.html#previous-components>.
error: 
error: If you are updating an existing toolchain, after determining the deprecated component(s)
error: in question, please remove them with a command such as:
error: 
error:     rustup component remove --toolchain stable <COMPONENT>...
error: 
error: After that, you should be able to continue with the update as usual.

  stable-aarch64-apple-darwin update failed - rustc 1.86.0 (05f9846f8 2025-03-31)

info: cleaning up downloads & tmp directories
info: self-update is disabled for this build of rustup
info: any updates to rustup will need to be fetched with your system package manager
```

Issuesを探してみると、以下のページがヒット。

https://github.com/rust-lang/rustup/issues/4339

元々 `rls` 自体は2022年に非推奨となっていたのが、1.87.0からエラーになるようになった？と予想されます。

というわけで、rls-previewコンポーネントを削除することに。

## 対応内容

インストールされているrustupコンポーネントの一覧を確認します。

```sh
$ rustup component list --installed
cargo-aarch64-apple-darwin
clippy-aarch64-apple-darwin
rls-aarch64-apple-darwin
rust-analysis-aarch64-apple-darwin
rust-src
rust-std-aarch64-apple-darwin
rust-std-aarch64-unknown-linux-gnu
rust-std-aarch64-unknown-linux-musl
rust-std-wasm32-unknown-unknown
rust-std-wasm32-wasip2
rust-std-x86_64-unknown-linux-gnu
rust-std-x86_64-unknown-linux-musl
rustc-aarch64-apple-darwin
rustfmt-aarch64-apple-darwin
```

`rls-aarch64-apple-darwin` 辺りが怪しそう。

冒頭のエラーメッセージの内容に従って `rls-preview` を削除します。


```sh
rustup component remove --toolchain stable rls-preview
```

コンポーネント一覧を確認します。

```sh
$ rustup component list --installed
cargo-aarch64-apple-darwin
clippy-aarch64-apple-darwin
rust-analysis-aarch64-apple-darwin
rust-src
rust-std-aarch64-apple-darwin
rust-std-aarch64-unknown-linux-gnu
rust-std-aarch64-unknown-linux-musl
rust-std-wasm32-unknown-unknown
rust-std-wasm32-wasip2
rust-std-x86_64-unknown-linux-gnu
rust-std-x86_64-unknown-linux-musl
rustc-aarch64-apple-darwin
rustfmt-aarch64-apple-darwin
```

`rls` 関連のコンポーネントが削除されていますね。

改めて `rustup update` を実行します。

```sh
$ rustup update
info: syncing channel updates for 'stable-aarch64-apple-darwin'
info: latest update on 2025-05-15, rust version 1.87.0 (17067e9ac 2025-05-09)
info: downloading component 'rust-std' for 'wasm32-wasip2'
 21.0 MiB /  21.0 MiB (100 %)   9.5 MiB/s in  3s         
info: downloading component 'rust-std' for 'x86_64-unknown-linux-gnu'
info: downloading component 'rust-std' for 'aarch64-unknown-linux-gnu'
info: downloading component 'rust-std' for 'wasm32-unknown-unknown'
info: downloading component 'rust-std' for 'aarch64-unknown-linux-musl'
info: downloading component 'rust-std' for 'x86_64-unknown-linux-musl'
info: downloading component 'rust-src'
info: downloading component 'rust-analysis'
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: removing previous version of component 'rust-std' for 'wasm32-wasip2'
info: removing previous version of component 'rust-std' for 'x86_64-unknown-linux-gnu'
info: removing previous version of component 'rust-std' for 'aarch64-unknown-linux-gnu'
info: removing previous version of component 'rust-std' for 'wasm32-unknown-unknown'
info: removing previous version of component 'rust-std' for 'aarch64-unknown-linux-musl'
info: removing previous version of component 'rust-std' for 'x86_64-unknown-linux-musl'
info: removing previous version of component 'rust-src'
info: removing previous version of component 'rust-analysis'
info: removing previous version of component 'cargo'
info: removing previous version of component 'clippy'
info: removing previous version of component 'rust-std'
info: removing previous version of component 'rustc'
info: removing previous version of component 'rustfmt'
info: installing component 'rust-std' for 'wasm32-wasip2'
 21.0 MiB /  21.0 MiB (100 %)  19.1 MiB/s in  2s         
info: installing component 'rust-std' for 'x86_64-unknown-linux-gnu'
 29.4 MiB /  29.4 MiB (100 %)  15.8 MiB/s in  1s         
info: installing component 'rust-std' for 'aarch64-unknown-linux-gnu'
 28.0 MiB /  28.0 MiB (100 %)  18.8 MiB/s in  1s         
info: installing component 'rust-std' for 'wasm32-unknown-unknown'
 19.6 MiB /  19.6 MiB (100 %)  19.4 MiB/s in  1s         
info: installing component 'rust-std' for 'aarch64-unknown-linux-musl'
 24.9 MiB /  24.9 MiB (100 %)  19.1 MiB/s in  1s         
info: installing component 'rust-std' for 'x86_64-unknown-linux-musl'
 37.9 MiB /  37.9 MiB (100 %)  19.1 MiB/s in  2s         
info: installing component 'rust-src'
info: installing component 'rust-analysis'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-std'
 27.0 MiB /  27.0 MiB (100 %)  19.2 MiB/s in  1s         
info: installing component 'rustc'
 60.4 MiB /  60.4 MiB (100 %)  19.8 MiB/s in  3s         
info: installing component 'rustfmt'

  stable-aarch64-apple-darwin updated - rustc 1.87.0 (17067e9ac 2025-05-09) (from rustc 1.86.0 (05f9846f8 2025-03-31))

info: cleaning up downloads & tmp directories
info: self-update is disabled for this build of rustup
info: any updates to rustup will need to be fetched with your system package manager
```

今度は無事Rustの最新版をインストールすることができました！

めでたしめでたし。

## 参考URL

https://github.com/rust-lang/rustup/issues/4339