Running `rust --version` fails after installing a rust standalone app on a linux system without internet

I installed the rust environment using the following steps:

  1. Download the linux stand-alone installation package from the official website: x86_64-unknown-linux-gnu.tar.gz
  2. Upload to linux and decompress tar.gz, the path is: /home/xcscsa/rust-1.70.0-x86_64-unknown-linux-gnu
  3. Enter the decompression directory, run sudo ./install.sh, the installation is successful
  4. Check the rustc and cargo directories, which are ~/.cargo/bin/rustc and ~/.cargo/bin/cargo respectively, and add them to the environment variable
  5. Run rustc --version, report:
    error: rustup could not choose a version of rustc to run, because one wasn't specified explicitly, and no default is configured.
    help: run 'rustup default stable' to download the latest stable release of Rust and set it as your default toolchain.
  6. Run rustup default stable, because the machine cannot connect to the Internet, it reports:
    could not download file from 'https://static.rust-lang.org/dist/channel-rust-stable.toml.sha256' to '/home/xcscsa/.rustup/tmp/ofq36f3folrolefe_file'
    Now, what should I do because the linux machine cannot connect to the internet, please help me, thanks~

try to edit the configuration file for rustup, see: Configuration - The rustup book

e.g. on my debian machine, it contains:

~/.rustup$ cat settings.toml
default_toolchain = "nightly-x86_64-unknown-linux-gnu"
profile = "default"
version = "12"

[overrides]

The standalone installer default to installing to /usr/local, not ~/.cargo/bin. The executables in ~/.cargo/bin/rustc and ~/.cargo/bin/cargo are coming from rustup and override the globally installed version in /usr/local. The easiest fix is probably rustup self uninstall to uninstall rustup. Rustup doesn't know anything about rustc toolchains that aren't installed through rustup itself.

1 Like

It can be taught, e.g. rustup toolchain link local /usr/local, and then you can use cargo +local ... or even rustup default local.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.