0
votes

I've just installed Rust in my system, which is Ubuntu 20.04.1 64x. In the end everything looked okay, but I can't run rustc:

$ rustc --version
Command 'rustc' not found, but can be installed with:
sudo snap install rustup  # version 1.23.1, or
sudo apt  install rustc   # version 1.47.0+dfsg1+llvm-1ubuntu1~20.04.1
See 'snap info rustup' for additional versions.

I'm completely new to the rust and I would like to try it but this issue complicate the process of learning. Would someone give a hint how to resolve the problem?


I visited the web

https://www.rust-lang.org/tools/install

and used the command from it:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Everything went as outlined on the web:

Welcome to Rust!

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

It will add the cargo, rustc, rustup and other commands to Cargo's bin directory, located at:

/home/daygeek/.cargo/bin

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

/home/daygeek/.profile /home/daygeek/.bash_profile

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

Current installation options:

default host triple: x86_64-unknown-linux-gnu default toolchain: stable modify PATH variable: yes

  1. Proceed with installation (default)
  2. Customize installation
  3. Cancel installation

Here I choose 1 option

info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu' info: latest update on 2018-12-06, rust version 1.31.0 (abe02cefd 2018-12-04) info: downloading component 'rustc' 77.7 MiB / 77.7 MiB (100 %) 1.2 MiB/s ETA: 0 s
info: downloading component 'rust-std'

54.2 MiB / 54.2 MiB (100 %) 1.2 MiB/s ETA: 0 s info: downloading component 'cargo' 4.7 MiB / 4.7 MiB (100 %) 1.2 MiB/s ETA: 0 s info: downloading component 'rust-docs' 8.5 MiB / 8.5 MiB (100 %) 1.2 MiB/s ETA: 0 s info: installing component 'rustc' info: installing component 'rust-std' info: in

stalling component 'cargo' info: installing component 'rust-docs' info: default toolchain set to 'stable'

stable

installed - rus

tc 1.31.0 (abe02cefd 2018-12-04)

at the end this message appeared:

Rust is installed now. Great!

To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH environment variable. Next time you log in this will be done automatically.

To

configure your current shell run source $HOME/.cargo/env

I messed up I know. Now I need a solution, or maybe I should try again but use different method?

2
How did you install it? There are several different methods. Please copy and paste the commands you used (and their output) if you can. - John Kugelman
Did you logout and login after installing rust? - wuerfelfreak

2 Answers

0
votes

According to https://www.rust-lang.org/tools/install (the site you cited for the installation) you need to make sure that your PATH variable is updated.

In the Rust development environment, all tools are installed to the ~/.cargo/bin directory, and this is where you will find the Rust toolchain, including rustc, cargo, and rustup.

Accordingly, it is customary for Rust developers to include this directory in their PATH environment variable. During installation rustup will attempt to configure the PATH. Because of differences between platforms, command shells, and bugs in rustup, the modifications to PATH may not take effect until the console is restarted, or the user is logged out, or it may not succeed at all.

If, after installation, running rustc --version in the console fails, this is the most likely reason.

Check that ~/.cargo/bin is present in your PATH by doing echo $PATH. If not try to relogin.
(See this question on how to change PATH manually if needed.)

You can also check whether rustc is actually present in ~/.cargo/bin

0
votes

The issue solved. I went through the installation process one more time and everything is ok. Thanks.