24

I installed rustup with brew command but still says that rustup command is not found. I am not sure if I am missing any installation step. Any help would be appreciated.

Rohith Joseph
  • 603
  • 1
  • 5
  • 17
  • Was the `rustup` binary installed anywhere? I mean, does a file with that name exist on your computer? Also, was the installation successful or did it have messages at the end? – piojo May 23 '21 at 05:04

7 Answers7

53

I used the following steps to install Rust on MacOS:

  1. Install Rust using:

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

    Make sure that you customize the installation and answer No when it asks to modify the Path.

  2. Once successfully done, then add the Path variable to .zshrc using:

    • To open .zshrc use nano ~/.zshrc
    • Add export PATH="$HOME/.cargo/bin:$PATH" to .zshrc
  3. Check if the installation was successfull using rustc --version
    If that doesn't work right away then use the command:
    source $HOME/.cargo/env and rerun rustc --version.

greybeard
  • 2,249
  • 8
  • 30
  • 66
lAaravl
  • 929
  • 2
  • 9
  • 20
  • What happens if we leave `modify PATH variable: yes`? I've seen other people install it this way, and I don't undetstand what difference it makes. In what way are we or are we not modifying the `PATH` variable? – Matt Sep 05 '22 at 21:55
40

To configure your current shell, run

source $HOME/.cargo/env 

this command FINALLY completed the painful installation of Rust.

Nand
  • 611
  • 6
  • 12
15

Make sure you has install rust successfully first setup

$ brew install rustup
$ source ~/.zshrc
$ source /.bashrc
$ brew reinstall rustup-init

now you can run command line

$ rustup-init

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/location/.cargo

modify PATH variable: yes

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

Nest Testing

To check if you have installed rust Succesful on your machine type the following command in your terminal

$ rustc

Once successfully done, then add the Path variable to .zshrc using:

To open .zhrc use

$ nano ~/.zshrc

or

$ open . ~/.zshrc

Add

export PATH="$HOME/.cargo/bin:$PATH"

to .zshrc, after that please run

$ source ~/.zshrc
$ source /.bashrc

To start a new project, navigate to where you want your project to be created then simply run cargo new <project-name>. In my case I have decided to name my project "todo-cli" so I can run:

$ cargo new todo-cli
Mattia Righetti
  • 1,265
  • 1
  • 18
  • 31
doctorlee
  • 437
  • 4
  • 5
5

I had the same problem, because the PATH variable didn't include the Cargo's bin directory right after installation.

I closed and opened again the shell, and it worked!

dimitris tseggenes
  • 3,031
  • 2
  • 16
  • 23
2

Did you try to install rustup via https://rustup.rs/

That may work correctly on your computer.

Penny Liu
  • 15,447
  • 5
  • 79
  • 98
IInfo
  • 52
  • 2
  • The instructions say NOT to do this if you already have Rust installed. ``` warning: it looks like you have an existing installation of Rust at: warning: /usr/bin warning: rustup should not be installed alongside Rust. Please uninstall your existing Rust first. ``` – Raleigh L. Oct 05 '22 at 04:33
1

By Running this code resolved my problems

export PATH="$HOME/.cargo/bin:$PATH"
0

i faced this issue in Ubuntu on WSL
Ubuntu terminal environment on Windows with Windows Subsystem for Linux (WSL).

I just restarted the terminal.
Thats all.

In your case u may require to reboot.

enter image description here

sifr_dot_in
  • 3,153
  • 2
  • 33
  • 42