rust-lang / rustup

The Rust toolchain installer
https://rust-lang.github.io/rustup/
Apache License 2.0
6.15k stars 885 forks source link

Installing Rust on an Aarch64 macOS machine where the settings.toml file was restored from an x86 machine #4054

Open jonathanpallant opened 1 day ago

jonathanpallant commented 1 day ago

Problem you are trying to solve

If you have a Aarch64 Apple machine where you've never installed Rust, but have managed to restore the .rustup folder from a backup of an x86-64 machine that did have Rust installed, the rustup installer will detect you have an aarch64-apple-darwin machine by parsing the uname correctly, but then switch to installing the x86_64-apple-darwin version of the toolchain. This is unexpected, and hard to spot as it will mostly work - except when you later try and link against some C libraries and it rejects the Aarch64 libraries you give it.

1) Proceed with standard installation (default - just press enter)
2) Customize installation
3) Cancel installation
>

info: profile set to 'default'
info: default host triple is aarch64-apple-darwin
info: syncing channel updates for 'stable-x86_64-apple-darwin'
...
info: default toolchain set to 'stable-x86_64-apple-darwin'

Solution you'd like

The installer should spot that a .rustup/settings.toml file exists, and print a message to explain that it is not installing the toolchain for the detected target, but instead the one it was asked to install in the configuration file.

Notes

No response

Xylakant commented 1 day ago

Steps to reproduce:

create ~/.rustup/settings.toml

default_toolchain = "stable-x86_64-apple-darwin"
profile = "default"
version = "12"

run the rustup installer:

~ % curl -sSL https://sh.rustup.rs | bash
info: downloading installer

Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  /Users/xylakant/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory is located at:

  /Users/xylakant/.cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

  /Users/xylakant/.cargo/bin

This path will then be added to your PATH environment variable by
modifying the profile files located at:

default_toolchain = "stable-aarch64-apple-darwin"
  /Users/xylakant/.profile
  /Users/xylakant/.bash_profile
  /Users/xylakant/.bashrc
  /Users/xylakant/.zshenv

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:

   default host triple: aarch64-apple-darwin
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with standard installation (default - just press enter)
2) Customize installation
3) Cancel installation
>

info: profile set to 'default'
info: default host triple is aarch64-apple-darwin
info: syncing channel updates for 'stable-x86_64-apple-darwin'
info: latest update on 2024-10-17, rust version 1.82.0 (f6e511eec 2024-10-15)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
 16.3 MiB /  16.3 MiB (100 %)   9.9 MiB/s in  1s ETA:  0s
info: downloading component 'rust-std'
 24.9 MiB /  24.9 MiB (100 %)   9.8 MiB/s in  2s ETA:  0s
info: downloading component 'rustc'
 59.6 MiB /  59.6 MiB (100 %)   9.9 MiB/s in  6s ETA:  0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 16.3 MiB /  16.3 MiB (100 %)   4.7 MiB/s in  2s ETA:  0s
info: installing component 'rust-std'
 24.9 MiB /  24.9 MiB (100 %)  20.4 MiB/s in  1s ETA:  0s
info: installing component 'rustc'
 59.6 MiB /  59.6 MiB (100 %)  21.4 MiB/s in  2s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-apple-darwin'

  stable-x86_64-apple-darwin installed - (timeout reading rustc version)

Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).

To configure your current shell, you need to source
the corresponding env file under $HOME/.cargo.

This is usually done by running one of the following (note the leading DOT):
. "$HOME/.cargo/env"            # For sh/bash/zsh/ash/dash/pdksh
source "$HOME/.cargo/env.fish"  # For fish