Failing to setup Rust on Mac

Hello guys, I am sure you might have already heard this question a lot of time before. I tried to look it up in the forum but couldn't find anything so if you could help me out that would be really appreciated.

I recently tried installing rust on my Mac m1. After i finished the installation, i ran the command rustc --version to look up the version and it showed the version installed. If i restart my terminal and run it again it says "zsh: command not found: rustc". From looking around online it seemed like an environment variable issue, but i have tried almost everything people suggested on places like stack overflow and github and nothing seems to work so far. Ever after placing the path in the nano file it still doesn't pick it up. If anyone can help me out with this or if anyone had a similar problem and figured out a way to fix it please let me know. Would be really helpful.

Although whenever i do run source $HOME/.cargo/env before running rustc --version (even after restarting terminal) it always runs succesfully.

I don't use zsh. But it sounds like that path of rustc is not in your shell session's PATH env var. So you need to somehow source $HOME/.cargo/env in your login profile. I don't know what this file is called for zsh. If you were using bash, it'd be ~/.bashrc or ~/.bash_profile.

This is what I have in my ~/.bash_profile:

source ~/.cargo/env
source ~/.config/bash_completion.d/rustup
source ~/.config/bash_completion.d/cargo

Hope this helps.

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.